Revoke Python to Uipath - error invoking python method - solved

Hi all, i done alot researches to revoke python script, manage to run while download others’ project, but when comes to my own script dont work.

My script is about running thing without any input or parameter. all are in the script.

Maybe you can imagine just like excel read cell “A1” and writing “hello world” in “B1”.

Short and simple, but cant run my script. just like normal .py, import package pandas, openpyxl. have no def or any method.

error message:

my Uipath setting:

, tried also single load or run, but not working.

please help

@damonyl, did you check this video ? If not, please go through this first.

#HappyRobotics

Hi @vikaskulhari, thanks for replying but as i mentioned my script not using def or any method that need return something, so i’m afraid this doesnt helps

alright but script must have a def.

do you mean add def abc in front of script?
but now i guess the error message also matter

can you please share your workflow and python script?

workflow shared in first posting.

python script:

import pandas as pd

import openpyxl

DateToday = pd.to_datetime(‘today’).strftime(‘%Y.%m.%d’)

col_names =

fn = ‘C:/Users/lida8002/Desktop/python/AU_output/MasterStep1.’+ ‘2019.09.241’+‘.xlsx’

fn1 = ‘C:/Users/lida8002/Desktop/python/AU_output/MasterStep.Summary.’+ “2019.09.241” +‘.xlsx’

#open new folder if not exist

try:

df1 = pd.read_excel(fn1)

except:

header = [“DBname”, “Step1 Status”, “Step2 Status”, “Step3 Status”, “Step4 Status”]

df10 = pd.DataFrame(columns=header)

writer = pd.ExcelWriter(fn1)

df10.to_excel(writer, sheet_name=‘Summary’, index=False)

swriter.save()

You need to keep your py code into a def and call def in UiPath.

1 Like

Use Run Python Script first and check @damonyl?

@damonyl - The thing is Python is a scripting language if code don’t have the class or function or definition or method but if you have used OOPS or the thing which I have mentioned it will work like programming language you are currently using it as scripting language.
Now if you want to use something like this you can use powershell activities to run you code or you can make the batch file and invoke it using UiPath.
Hope it will help you.

Best!!
Anmol

Hi all, thanks for giving your opinion, really appreciated.

Maybe let me clarify my problem and giving solution that solved mine problem.

I’m able to import package while using Anocanda, but if running with UiPath, need to pre-install in Python, where you can check it out from running Python 3.6, if your type import pandas (or any other package) it shown error, means you’ve not installed PIP yet. that’s the main reason make me failed also.

Action:- locate your python file and open “Scripts” folder, for me is (C:\Users\Damon\AppData\Local\Programs\Python\Python36\Scripts), copy this path and run CMD, type cd C:\Users\lida8002\AppData\Local\Programs\Python\Python36\Scripts and then type “pip install pandas”, replace pandas with any package you want to install.

In Uipath perspective, any script, for mine, not function or def function, still manage to run.

Activity in UiPath to be used, Load Python script and Run Python Script. that’s all

hope this helps

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.