We are trying to run a python code (script attached – ExcelTest.py) with UiPath (workflow attached – FuncExcelTest.xaml). We manually import some external libraries to python (eg openpyxl) and, when trying to run the python code manually works but, through UiPath it give us the error “No module named ‘openpyxl’” (attached in the picture C511092.png).
Is there any way we could invoke a python script using non-builtin libraries?
Many thanks in advance!
Find attached the XAML file FuncExcelTest.xaml (7.0 KB)
The python script :
I encountered the same problem when using “import openpyxl” or “import pyodbc” in the Python script. The script worked fine in Python, but when I tried using the Invoke Python Method in UiPath, the code failed with an error. I determined that UiPath was not seeing the files related to openpyxl or pyodbc when using the Invoke Python Method in UiPath. UiPath is not looking in the working folder for these files. It is looking in the Python scripts folder. I discovered that on a Windows computer you need to launch a command prompt and navigate to the pythons scripts folder. On my computer, it was “C:\users\username\AppData\Local\Programs\Python\Python38-32\Scripts”. But, you need to replace username in the path with your Windows user name. From this folder I ran the following command:
“python -m pip install -U pip setuptools”
This code enabled the ability to do a pip install in the Python scripts folder. Then I executed the following commands in the Python scripts folder:
“pip install openpyxl”
“pip install pyodbc”
After taking these actions, the Python script ran with no problems.