How to troubleshoot Python activity related errors?
Perform the below steps:
Step 1: (Validate the configuration parameters)
- Check the Python exe file path location is properly specified in Python Scope properties.
- Check the installed Python version is 64-bit or 32-bit. In case of 32-bit version select x86.
- Specify the Python version installed. It is always better to specify the Python version rather selecting 'Auto'.
- Instead of using "Run Python Script" activity, use Load Python Script -> Invoke Python Method -> Get Python Object.
- Remove the print statements in Python code.
- 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.
- 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.
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")
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: