Python Activity Troubleshooting

Step-A: (Validate the Configuration parameters)

  1. Check the Python exe file path location is properly specified in Python Scope properties
  2. Check the installed Python version is 64-bit or 32-bit. In case of 32-bit version select x86
  3. Specify the Python version installed. It is always better to specify the Python version rather selecting Auto.

Step-B:

  1. Instead of using " Run Python Script " activity, use Load Python Script → Invoke Python Method → Get Python Object .
  2. Remove the Print statements in Python Code

Step-C:

  1. If there is any error related to dependency/Package not found, please check if for the specified python instance (Configured in Python Scope) that package is installed. You can check the package is already installed by executing the command “pip install ” . If it is already installed, it should prompt as “Requirement already satisfied” as below.
  2. If you have any python distribution installed in system like Anaconda, it installs packages in its directory only. Check python file you are trying to run from UiPath can be run from the command prompt for the specified installation. If any dependency is missing. install the dependency first.

Step-D:
In most of the cases executing python code from UiPath doesn’t give the proper error,
As Python is an interprited language, every statement is executed separately. Use following code snippet to identify which line is causing the issue:

outF = open ( "myOutFile.txt" , "w" )

outF.write("Test line1 added")

outF.close()

Step-E: (Work around)
If using Python activity, you are still getting error though the file can be run successfully from Command Prompt or Python IDLE. Run the python file from Powershell as below:

12 Likes

Thank you so much for your post!

1 Like

Great post, very useful :+1:

My python script not execute when i run in UiPath.Python.Activities version 1.1.6863.33404.
But when i run version 1.0.7346.28183, it run well because in this version have WorkingFolder and i can fill it.

My question, how i can run my python script in version 1.1.6863.33404

1 Like

Hello @Tuhin_Samanta,

Any idea how to deal with unicode errors when your script file is “utf-8” encoded and contains non ascii characters?

A simple script like that (no practical purpose :)) will fail:

my_string = "Modèle"

I can “transcode” to another charset but all my python environment is tunned to produced utf8 content.

20.10.4-beta.1+Branch.release-v20.10.4.Sha.37d549846d5ef51c36ecc7e3bab8ad2ae1436ee9

Source: Load Python Script

Message: One or more errors occurred.

Exception Type: System.AggregateException

RemoteException wrapping System.AggregateException: One or more errors occurred. —> 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]]: ImportError : No module named skimage

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__DisplayClass13_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 inner exception stack trace —
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)
can someone help me with this error, i have scikit-image package already installed in my system and python script is properly running using cmd also.

Hi @roopali_jain ,
as he said in his first post, if UiPath still doesn’t manages to find the module (And your code runs properly elsewhere), then make it run through powershell comand or start process.

I prefer the later. How to do it?

  1. create your script myscript.py
  2. create a batch file runmyscript.bat
  3. in UiPath, use the activity Start Process with the path towards your .bat

Need help doing a .bat? have a look here : How to Create a Batch File to Run a Python Script - Data to Fish

1 Like

I would like to add that if you’re using distribution Anaconda, you may face issues with importing some library packages when doing a load script activity.

Solution:

From anaconda3\Library\bin copy below files and paste them in anaconda3/DLLs:

  • libcrypto-1_1-x64.dll
  • libssl-1_1-x64.dll