Looking Assistance for Python

Hi Brilliants and @jeevith
I am looking assistance to run python script. In my script I have imported a module. My Script is running fine from pycharm but when I am try to run if from Uipath I am getting error.
Error Details:

I have created another script without import any module which is ran fine from uipath.

Please assist me.

-Jesmine

Hi @Jesmine ,

Could you pls refer the below thread it might helpful for you to resolve the issue. Thanks.

Hi @Jesmine,

Could you show us what is being returned from python function/script i.e., what value are you trying to return?

def something(input):
   return  ??

Some threads for you to read about Pipe is broken error, which I have come across and some reasons for it.

Thanks for quick response. Already seen but not yet resolve.

Thanks for quick response. Please check inbox.There is no option to share one to one.
I have used hard-coded to pass input file path as pdf. And output as csv. Also import camelot.

Thanks

Hi @Jesmine

Which version of python was installed on your system ??

Hi @Jesmine,

Just so you know, I have not received a DM. But if you are returning nothing you can just run the function (call the function in UiPath) and not return anything back as you have a location where the python file will create a csv.

Later you can use path exists to check if the csv file is created or not in your UiPath workflow.

Hi @Robinnavinraj_S
I have used 3.9 and I have successfully ran another python program by it. But This program through error.
Thanks

hi @Jesmine

Currently you are using python 3.9 version. Kindly either downgrade the current version to 3.6 or download and install python 3.6 version and use that path into python scope

then retry the process again and update us

Thanks,
Robin

Hi @jeevith , I believe it will resolve by you. My issue not yet resolve. I am sharing the code. If need then please share the modify or suggest me the way.

Code:
import camelot
tables= camelot.read_pdf(“C:/Users/jesmine/Documents/UiPath/TabularPDF/OSC/3001.pdf”)
tables.export(“C:/Users/jesmine/Documents/UiPath/TabularPDF/OSC/30001_2.csv”)

when import module camelot it will throw an error “pipe is broken”
Note: It perfectly run from jupyter.
Please assist me to execute my code

Thanks

Hi @Jesmine ,

i wanted to provide suggestion on the requirement( i understood you want to convert your PDF to csv file). i am sorry i am going little off track on your question. if you are allowed to use custom package in your project can we try with below custom package it will help us to convert the PDF to csv. please refer if you want to try. thanks.

Thanks for your concern. I am not looking to convert pdf to csv. I need to execute my query on my machine for python

Hi @Jesmine,

Maybe we can understand the problem clearer by trying out different Python examples.

For Example, we can test with other modules instead of camelot and get to a conclusion whether if it’s a problem with a Specific module or the Configuration of the Python Scope that is being used.

You can test it with Other Samples of Python Code. The reason I am suggesting this is because I too got the Same error "Pipe Broken" when I used xlsxwriter module.

To Solve this issue, I had to first install the module 'xlsxwriter'. To do it I followed the below Steps:

  1. Opened Up my Command Prompt.
  2. Copied Full Path of Python Scripts folder C:\Users\[Username]\AppData\Local\Programs\Python\Python37-32\Scripts
  3. Used the below Command to change the Directory to the Scripts Folder.
    cd C:\Users\[Username]\AppData\Local\Programs\Python\Python37-32\Scripts
  4. Next, used the command to install xlsxwriter as below using pip
    pip install xlsxwriter

After this I had provided the Folder Path of the Script as the WorkingFolder Property value.
Then I was able to use the Below Python Code in UiPath, which will create an xlsx file.

def call_function_uipath():
    import xlsxwriter
     
    # Workbook() takes one, non-optional, argument
    # which is the filename that we want to create.
    workbook = xlsxwriter.Workbook('hello.xlsx')
     
    # The workbook object is then used to add new
    # worksheet via the add_worksheet() method.
    worksheet = workbook.add_worksheet()
     
    # Use the worksheet object to write
    # data via the write() method.
    worksheet.write('A1', 'Hello..')
    worksheet.write('B1', 'Geeks')
    worksheet.write('C1', 'For')
    worksheet.write('D1', 'Geeks')
     
    # Finally, close the Excel file
    # via the close() method.
    workbook.close()

The UiPath Workflow Looks Like below :
image

Path Property Value :
image

WorkingFolder Property Value : The Folder where the Python Script is Placed.
image

Property of Load Python Script Activity:
image

Property of Invoke Python Method :
image

Do let us know if it works out or if you have got the Solution already, Please Do post the Solution.

1 Like

Thanks a lot. Will get back soon once I check.

1 Like

Hi @supermanPunch, It was nice explanation. Issue was camelot. I have successfully ran your script. But when I import camelot it throw an error. Already installed dependencies in script folder based on your path. But still throw an error. How to resolve the error?

-Thanks

Hi @Jesmine ,

After a Much done trial and error methods, and making some configurations, It seems it did work for me to use Camelot as there were no errors, but however I don’t get any output generated from the Script that you have provided.

Please Check if these configurations are already done in your system.

  1. As camelot requires Ghostscript and tkinter, have you installed it before installing camelot?

  2. Also whether GhostScript application is installed ?

If the above are already done, then Check if the below PATH values are maintained in Environment variables in your system.

  1. C:\Program Files (x86)\gs\gs9.55.0\bin - The Bin Folder present in the GhostScript application folder Path.

  2. C:\Program Files (x86)\gs\gs9.55.0\lib - The Lib Folder Present in the GhostScript application Folder Path.

  3. C:\Users\[Username]\AppData\Local\Programs\Python\Python37-32\Scripts - The Scripts Folder path of the Python Executable.

image

Let us know what are the results of this Diagnosis.