# Importing the python script to uipath/ Error loading Script

**URL:** <https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983>\
**Category:** Something Else\
**Tags:** python, activities\
**Created:** [April 11, 2020, 7:55am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983 "2020-04-11T07:55:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 11, 2020, 7:55am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/1 "2020-04-11T07:55:28Z")

</div>

anyone knows how to solve this error?

import speech\_recognition as sr  
import webbrowser as wb

chrome\_path = ‘C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s’

r = sr.Recognizer()

with sr.Microphone() as source:  
print (‘Say something’)  
audio = r.listen(source)  
print (‘Done’)

try:  
text = r.recognize\_google(audio)  
print(‘Google thinks you said:\n’ + text)  
wb.get(chrome\_path).open(text)

except Exception :  
print

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 12, 2020, 11:17pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/2 "2020-04-12T23:17:43Z")

</div>

Hello,

Did you tried this script outside UiPath? Could you show you Invok Python Script activity?

Working with python in UiPath is really a PITA as it is now:

- **Encoding errors**  
You can’t work with non-ASCII without adpating your python

- **PYTHONPATH**  
Well, if you work with packages, importing other modules is quite a sport.

- **Traceback**  
Don’t ask for it 🙂 You’d better have solid logs. To begin with,

> <https://stackoverflow.com/questions/1508467/log-exception-with-traceback-in-python>

```python
# Your script with formatting
import speech_recognition as sr
import webbrowser as wb

chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

r = sr.Recognizer()

with sr.Microphone() as source:
	print ('Say something')
	audio = r.listen(source)
	print (‘Done’)

try:
	text = r.recognize_google(audio)
	print('Google thinks you said:\n' + text)
	wb.get(chrome_path).open(text)
except Exception:
	print

```

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 13, 2020, 7:33am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/3 "2020-04-13T07:33:47Z")

</div>

sorry, I don’t unds… please explain. thanks!

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 13, 2020, 11:15am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/4 "2020-04-13T11:15:55Z")

</div>

Could you please make a screenshot of your **Load Python Script**? Did you try to run your script from the command line before integrating it to UiPath?

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 13, 2020, 12:33pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/5 "2020-04-13T12:33:28Z")

</div>

![IMG-20200413-WA0004](https://global.discourse-cdn.com/uipath/original/3X/d/2/d21933f026f6151f4cbef3ddb92f2a0c469d1172.jpeg)

Yes it works fine before integrating it to uipath.

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 13, 2020, 3:31pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/6 "2020-04-13T15:31:35Z")

</div>

Nice.

Could you make a screenshot of your **Load Python Script** activity in UiPath, please?

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 14, 2020, 2:06am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/7 "2020-04-14T02:06:43Z")

</div>

![IMG-20200414-WA0000](https://global.discourse-cdn.com/uipath/original/3X/1/d/1d92ef4af31c7d25830bcc0c4adc600ef7551990.jpeg)

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 14, 2020, 4:10am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/9 "2020-04-14T04:10:51Z")

</div>

![IMG-20200414-WA0001](https://global.discourse-cdn.com/uipath/original/3X/0/c/0ca429c0d2022344ecf746089f96b7b2f63c5252.jpeg)

this is the error when I run…

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 14, 2020, 4:51am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/10 "2020-04-14T04:51:07Z")

</div>

Thanks

If the following doesn’t fix your problem, could you please click on “Details” in the error and copy/paste the content?

Just thought about it: I’m not sure what is the standard output for your prints when launched from UiPath. In this context, I would let UiPath print the instructions. The script should return the string to print as a result and you’ll manage the resulting print from UiPath

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 14, 2020, 5:48am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/11 "2020-04-14T05:48:35Z")

</div>

the content is this "RemoteException wrapping System.InvalidOperationException: Error loading Python script —\> RemoteException wrapping System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: ModuleNotFoundError : No module named ‘speech\_recognition’

Server stack trace:  
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)  
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)  
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)  
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)  
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:  
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)  
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)  
at UiPath.Python.Service.IPythonService.LoadScript(String code)  
at UiPath.Python.Impl.OutOfProcessEngine.\<\>c\_\_DisplayClass11\_0.b\_\_0()  
at System.Threading.Tasks.Task`1.InnerInvoke()  
at System.Threading.Tasks.Task.Execute()  
— End of stack trace from previous location where exception was thrown —  
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)  
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)  
at UiPath.Python.Activities.LoadScript.d\_\_12.MoveNext()  
— End of inner exception stack trace —  
at UiPath.Python.Activities.LoadScript.d\_\_12.MoveNext()  
— End of stack trace from previous location where exception was thrown —  
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)  
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)  
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)"

the output is supposed to be like eg. when i say "open [youtube.com](http://youtube.com) " then it would open

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 14, 2020, 5:51am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/12 "2020-04-14T05:51:28Z")

</div>

Erf…I can’t make sense of that, sorry…

Could you comment the prints in your script and run UiPath? Just to put my theory in trial.

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 14, 2020, 6:55am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/14 "2020-04-14T06:55:51Z")

</div>

could you show me how to do it? as I’m not sure how.

([UiPath Voice Command - YouTube](https://www.youtube.com/watch?v=fvs29wjFKy8))

£I would like the result to be similar to the video.

thanks.

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 14, 2020, 7:53am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/15 "2020-04-14T07:53:05Z")

</div>

I understand, we’ll come to the result later. (I’ll watch your link in about 2-3 hours.

```python
# Your script with formatting
import speech_recognition as sr
import webbrowser as wb

chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

r = sr.Recognizer()

with sr.Microphone() as source:
	# print ('Say something')
	audio = r.listen(source)
	# print (‘Done’)

try:
	text = r.recognize_google(audio)
	# print('Google thinks you said:\n' + text)
	wb.get(chrome_path).open(text)
except Exception:
	pass

```

EDIT: I saw the video 😉 Once you’ll check that getting rid of the prints fix the problem, you might want to choose between:

- Write to a file (you can use Notepad++ to monitor file as soon as it change, see screenshot below)
- Change the standard outpout
- Return the results and handle back and forth communication between UiPath and Python.

![image](https://global.discourse-cdn.com/uipath/original/3X/4/6/46ffe749a6d9948c5e43798ebb13cffd51b27f01.png)

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 14, 2020, 1:53pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/16 "2020-04-14T13:53:53Z")

</div>

sorry I still dont get it…

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 14, 2020, 3:38pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/17 "2020-04-14T15:38:25Z")

</div>

Could you please use my edited version of your python script and see if chrome open?

---

<div class="post-metadata">

**Author:** ![Yashpal\_Singh](https://avatars.discourse-cdn.com/v4/letter/y/7bcc69/32.png) [@Yashpal\_Singh](https://forum.uipath.com/u/Yashpal_Singh)\
**Post date:** [April 14, 2020, 6:19pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/18 "2020-04-14T18:19:14Z")

</div>

very impressive

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 15, 2020, 3:31pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/20 "2020-04-15T15:31:07Z")

</div>

I still don’t understand, the code is shown when i run in chrome. can you show me how?

thanks.

---

<div class="post-metadata">

**Author:** ![msan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/msan/32/110167_2.png) [@msan](https://forum.uipath.com/u/msan)\
**Post date:** [April 15, 2020, 3:57pm UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/21 "2020-04-15T15:57:05Z")

</div>

When you use the code I edited and launch your UiPath Script, what happen?

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 16, 2020, 11:06am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/22 "2020-04-16T11:06:23Z")

</div>

![IMG-20200416-WA0001](https://global.discourse-cdn.com/uipath/original/3X/8/6/86cc57f096838a5a0dc128fb0668cfc2962723a9.jpeg)

the same error will appear. please show me how. thanks.

---

<div class="post-metadata">

**Author:** ![anon31352751](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon31352751](https://forum.uipath.com/u/anon31352751)\
**Post date:** [April 20, 2020, 4:08am UTC](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983/23 "2020-04-20T04:08:07Z")

</div>

can you please help me?🙂

[Next page](https://forum.uipath.com/t/importing-the-python-script-to-uipath-error-loading-script/210983.md?page=2)
