Mini-tut: getting started with Python

Hello all,
After a long hiatus I’ve been able to start to work with UiPath a little once again. I was very pleased to find Python activities available, but I ran into a snag here and there. I’m sharing a simple workflow to get you started. I’ll update this mini-tut as I complete more workflows.

To start, you’ll need to make sure you have Python activities available, even if you’ve loaded them for other projects, and might expect to find them already available in your new project. In 2019.6, that wasn’t the case for me. From “Manage Packages”, make sure you have this installed:

We’re going to keep this as simple as possible. All there is is a Python Scope activity, and one Load Python Script Activity. Here’s an overview of what your sequence will look like:


The Python Scope entries are crucial. I was NOT able to work with Python 3.7 64-bit, my system default. So I installed 64-bit Python 3.6 in ‘C:\Python36’. I used the generic download from Here’s what the scope properties panel looks like for me:


That’s a variable in the Input → Path field (the only one we’ll use). The entry looks like this:

In the Expression Editor for the variable, it looks like this:


Here is the Load Python Script activity, seen as when double-clicking on it.


Now we want to load that Python script as shown. For our purposes, we won’t add a path. I’m assuming the EVERYTHING is in the project directory - .xaml, python script, and output text file. Take a look at the properties:


And here it is in the Expression Editor (remember, no path needed for this simple exercise):


Okay, we’re ready to run the Python. Here’s the contents of the script:

f = open("C:\\Users\\YourUserName\\Documents\\UiPath\\InvokePython\\helloworld.txt", "w")
f.write("Hello World from UiPath running Python. This time the script is loaded, not code.")   

As you can see, you WILL have to change the path here, IN the file ‘’, to let UiPath know where to put the output text file.

WARNING: If you don’t add this absolute path, UiPath will drop ‘helloworld.txt’ in the folder where the NuGet package is, and you in all probability don’t want that. There are a number of posts about this elsewhere on the forum, but first things first.

About the attached files: I’m including ‘Py5.xaml’, and ‘’. Be sure to rename the Python file to ‘’ once you’ve edited it to add the path as above, or else change the fields in the script. Your choice.

By all means let me know if this doesn’t work for you. I’ll be adding at least one more version (using code in the ‘Load Python Code’ activity instead of loading a script to run.

Once again - change that file path! :slight_smile:

burque505 (2.0 KB)


Second installment: Providing code in the UiPath Expression Editor, and not from a script.

(First, see @ronanpeter’s solution for plenty more information.)

The only difference between this workflow and the previous one is where we put the python code. In this version, everything is basically the same, but the code goes here:


This by itself doesn’t tell you much, but take a look at what’s in the expression editor:

So you can paste the python code in if you like, here it is:

f = open('C:\\Users\\Winter\\Documents\\UiPath\\InvokePython\\helloworld.txt', 'w')
f.write('Hello World from UiPath running Python. Using Code input instead of File.')

Notice that you can use a multiline string now. In the past you might have had to write something like this:

"f = open('C:\\Users\\Winter\\Documents\\UiPath\\InvokePython\\helloworld.txt', 'w')" + Environment.NewLine + "f.write('Hello World from UiPath running Python. Using Code input instead of File.')" + Environment.NewLine + "f.close()" + Environment.NewLine + ""

What a pain to code! Oh well, you don’t have to do it any more.

I’ve quite wrongly assumed here that you’d be using a VB.Net based workflow. You may prefer C# and by using that for your processes. If you are using C#, this next screenshot may well be superfluous for you, but in case you’re just getting started with C# too, here it is:

As you can see, the only real difference is the “@” preceding the multiline string. Here’s the code in case you want to paste it in:

f = open('C:\\Users\\Winter\\Documents\\UiPath\\InvokePython\\helloworld.txt', 'w')
f.write('Hello World from UiPath running Python. This is a C-sharp process.')

I hope this is of some use to you.
Best regards,

1 Like

Currently i m working on python activities to get to a URL and get the output from that URL (like how we do in web services), is that possible with this python activity buddy
Cheers @burque505

@Palaniyappan, if you haven’t already tried it, take a look at Beautiful Soup. The home page has links to a number of projects you may be able to adapt to your purposes. The most up-to-date version can be installed with pip, and you can find info on it here.
Good luck with it!
Best regards,

Let me try that once and will let you know
Cheers @burque505

Third installment:
This is a really simple way to get a Python 3.7.3 script running and pull in all the required packages.
All it takes is a sequence with one “Start Process” activity to call your version of Python with arguments.

NOTE: The attached .xaml won’t work for you as-is. You’ll need to match the Python program path and the argument path to suit your system. The attached script, “widgets_example_pyside.pyw” WILL require that you install pyside on your system (“pip install PySide2”, probably), but other than that should work.

Start Process properties:

The sequence:

The output:

burque505 (3.9 KB)

Below tutorialon python in UiPath

I have followed same process but my code getting stucked at python scope even I have provided all details