I am trying to load a simple python script, which should work (I got it from uipath forum concerning python), but when I run the workflow, I get an error which states:
I have installed python 3.6 at C:\Python36 and tried to execute the example program. getting an error for pythn script load activity may be because of the file paths. Could you please help me on this. attached the zip file.Python36.zip (59.4 KB)
There was a minor syntax error in your python script.
Previous syntax : print data
Corrected Syntax: print(data)
I have made the changes and tested with UiPath.
It’s working good now.
Even I have a similar issue - Error loading python script, I’m not attaching .py file in load python script instead hard coded the code in the activity. Could you pleas help me resolve this.
Using Python 3.6 - 32 Bit
import hmac
import hashlib, sys
import base64
import time
import math
key=“AKI1339272018102317140956787461”
data = str(math.trunc(time.time()))
print (data)
a = base64.b64encode(hmac.new(b’key’, b’msg=data’, digestmod=hashlib.sha256).digest())
print (a)
This code calculates Epoch time and Digest using Epoch Time and AKI.
I have attached my workflow, thanks for your time. TEST.xaml (9.6 KB)
I have attached the .py file and loaded the python script. It worked fine. But whenever you want to return the output make sure you write a python program using a function and use Invoke python method activity to pass the inputs. I’m attaching the Python file along with the workflow. Please go through it and reply back if there’s any concern.
In the python scope, make sure u give the target as x86 as you are using python 32 bit.
I’m not able to attach the python file. So typing it here:
def Apachfn(keyinput):
import hmac
import hashlib, sys
import base64
import time
import math
key=keyinput
data = str(math.trunc(time.time()))
print (data)
a = base64.b64encode(hmac.new(b’key’, b’msg=data’, digestmod=hashlib.sha256).digest())
print (a)
return("Data: “+data+” "+"A: "+str(a))
I am getting the same error in load python script activity.
Here is my python code. There are no errors in the python editor that I have used and when i run it directly the script is executing. But while loading the script in uipath its giving an error as mentioned above by Sirtosych. Please find the code below:
from bs4 import BeautifulSoup
import os
def download():
canID = “123456”
filepath = r"C:\Users\abhilashasinha3\Desktop"
f = open(os.path.join(filepath, canID, “cv_webpage.html”), “r”)
soup = BeautifulSoup(f.read(),‘html5lib’)
table_body = soup.find(“table”, {“class”:“docs_upload_table”})
lst = list()
title = ‘’
for tr in table_body.find_all(‘tr’):
if tr:
typ = tr.find_all(‘td’)
if typ:
if not typ[0].find(‘a’):
title = typ[0].get_text()
if tr.find(‘a’):
lst.append({‘type’ : title, ‘document’ : tr.find(‘a’).get_text(), ‘onclick’:tr.find(‘a’).get(‘onclick’)})
with open(os.path.join(filepath, canID, "output.csv"), 'w') as fr:
for item in lst:
fr.write('{},{},"{}"\n'.format(item['type'],item['document'],item['onclick']))
return lst
I have attached the workflow and I have commented out an if condition where there is no statement in the IF condition. Please find the attached workflow. Main.xaml (6.9 KB)
Hii rahul
I have a python script which is not giving any error when i run the code in cmd but when i have loaded it in uipath it is giving error failed to load python script.
Attaching the workflow. Please get back if there are any issues.
Make sure the PDF file is at the same path.
And also, it would be advisable to pass the arguments into the Python script. CultivationFacilityScoreBreakdown.zip (11.7 KB)
Hi Rahul,
Error is resolved but python script is unable to read pdf .I have given file name and that pdf is in same directory of xaml file and python script .PFA image of error occurred .