Not Able to import python packages : throws Error Loading Python Script

I’m not able to import installed Python Packages in Load Python Script activity. It throws error, without the package it runs. And I tried with sys.path.append(os.path.dirname(os.path.abspath(“file”)))
statement and still it throws error. Please look into my code below,

<import sys 
import os
sys.path.append(os.path.dirname(os.path.abspath("__file__")))
import pdf2image
import re
import io

def Hello():
   return 'Hello'
>

Here I need to pdf2image package and it is already installed. Along with that i need to use some more packages. Please help me to fix it

Hi @noufalahammed

Could you show us how you set it in UiPath?

Also, could you see if any of these topics help you? :slight_smile:

Ws ths issue resolved?
For me UiPath crashes when I import local files.

1 Like

No… I used alternative solution to run my Python code.
I created a batch file to run python file and used ‘Start Process’ activity to run batch file

Please go through this basic workflow.
Gives you a better idea on integration with python.
Main.xaml (7.5 KB)

This will work…But when you import external package for python it wont work.
You add ‘import pytesseract’ in your code and some relevant operation like extraction data from image or something… Then if it is working please let me know

This is a workflow which I integrated with Uipath.
And yes I used Tesseract Library to extract the data and it worked fine for me.
OCR.zip (2.5 KB)

1 Like

Can you please share the python code what you have used…
Thanks in advance

Sure. Attaching the file.
Please let me know if you’re stuck anywhere.
OCCRR.zip (1.4 KB)

2 Likes

It still throws error that it cannot load python script. And I used your code to run.
Tell me one thing, does Uipath supports python-64 bit?
Because I’m using 64 bit version of Python(3.6)

It does is what the latest update depicts.
Could you try it out with 32 Bit version and share the result?

It did not work with 64 bit. 32 bit perfectly works. and UiPath only accepts from 2.7 to 3.6 versions of Python

It doesn’t create any text files while running from uipath. It creates if it executed from python shell.

hello team,

i tried to greyscale an image with PIL.
it works fine with python alone but when i try with uipath it says : “ModuleNotFoundError : No module named ‘PIL’”.

how can i fix this ?

thanks

Hello Grish,

UiPath works on base Python which may not have all the dependencies of the packages we import in Python script. For e.g., xlrd package may be absent and your script need it as a dependency. Install xlrd or any other package(which your script needs) in the Python version which you linked to UiPath. It should work fine.

1 Like

Hi @noufalahammed , @Rahul_Pasupuleti

DId you manage to solve this? I am facing same issue,

from tkinter import filedialog

#below filedialog operation will throw error. It is ok when I run it on Spyder
targetPath = filedialog.askopenfilename(title='select file to upload')

Thanks!

Jack

No OCCRR.py attached, so we don’t see if any IMPORTS of custome .py files are used…