Python Activity Troubleshooting - KB

How to troubleshoot Python activity related errors?

Perform the below steps:

Step 1: (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'.
image.png

Step 2:
  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 3:
  1. If there is any error related to dependency or package not found, check for the specified python instance (configured in Python Scope), if that package is installed. Check if 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.
image.png
  1. If any Python distribution is installed in system like Anaconda, it installs packages in its directory only. Check the Python file that is tried 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 4:
As Python is an interpreted language, every statement is executed separately. Use following code snippet in the Python file within every function or after some code blocks to identify the point of failure:
outF = open("myOutFile.txt", "w")
outF.write("Test line1 added")
outF.close()

Step 5: (Work Around)
If the Python script runs successfully from Command Prompt or Python IDLE but fails while executing via UiPath Python activity, run the Python script via Powershell activity as shown below:

A post was split to a new topic: Suggested Python version