How To Execute Python Script – In UiPath

We might sometimes think of writing python scripts to automate few tasks or to achieve some desired results.

let’s see how to do that…!!!

Mandatory: UiPath.Python.Activities package

Example

Implementation using UiPath :

Let us implement a workflow which takes name and country and displays a proper welcome message using a python script.

Step 1:
Drag “Python Scope” activity into the designer panel and set the required parameters.

Path:
Your python installed path i.e. “C:\Users\sharathm\AppData\Local\Programs\Python\Python36”
Version:
Select your current version .i.e 3.6,3.5,2.7…

UiPath Execute Python Script 1UiPath Execute Python Script 2

Step 2:
Drag “Load Python Script” activity into the designer panel to load the python script and supply the below parameters.

File: Your python script path
Result: Create a PythonObject type variable and pass it here

Our Python Script:
UiPath Execute Python Script 11.PNG

Load Python Script Activity:
UiPath Execute Python Script 3UiPath Execute Python Script 4

Step 3:
Drag “Invoke Python Method” activity into the designer panel and supply the function name that we want to invoke with the required arguments to it.

Function Name: Welcome
Here we have used two arguments i.e
Name: Sharath
Country: India

UiPath Execute Python Script 5UiPath Execute Python Script 6

Step 4:
Drag “Get Python Object” activity into the designer panel to convert the python Object obtained from the above activity to our desired datatype (In our case its “string” type)

UiPath Execute Python Script 7UiPath Execute Python Script 8

Step 4:
Drag “Message Box” activity to display the welcome message obtained from the script.

UiPath Execute Python Script 9

Step 5:
Finally, execute the workflow 🙂

UiPath Execute Python Script 10

Click here to download the Source Code…

Hope it has helped you…

2 thoughts on “How To Execute Python Script – In UiPath

  1. Kev 26

    install your source code and get error –> Load Python Script: Error loading Python script. 🙁

    1. No worries
      So, which version of python are you using currently?

Leave a Reply

%d bloggers like this: