Retrieve Output/Return value (simple/complex structures) from Python Scope in UiPath


I am trying to use the newly added Python activities to automate a particular flow, but I’m facing issues in the “Get Python Object” Activity.

The python program returns a number or a string (say). The Python code is executed using the “Load Python” Activity inside the “Python Scope”.

One thing that we’ve noticed is that “Run Python” Activity cannot retrieve an Output but “Load Python” Activity can.

I’m passing the Output from “Load Python” Activity to “Get Python Object” Activity which would convert it to .Net format but the workflow seems to fail at this point.

Following is the screenshot of the same.


Also, the python program when executed via IDLE or PyCharm executes as expected and provides the required result. It doesn’t take any inputs and just prints/returns a message on the screen.

Any idea what causes this exception? Or how I might fix this?

Abdullah Nasir


The “Load Python Script” Activity gives OutArgument < PythonObject > as a result that can be stored in a variable. The variable was of type PythonObject.

I ran the variable through a message box with a dotToString and found this. (Refer Screenshot below)


I expected it to have the python-return-value stored in it, but is this ambigous behaviour, or am I doing something wrong?

Anny Updates ?

To get this working you need to do the following:

Use a Python scope
Load the python script, the data you wish returned must be the return value of a function in the script. The Python file can have many functions in that you can call at will
Invoke Python Method - this runs the function you wish
Get Python Object- this actually returns the output from the function for printing or further processing

My test workflow looks like this, a simple workflow that takes two integers and Python sums or multiplies depending on the function I call returning the answer

and the Python is simply

def sum(a,b):

def multiply(a,b):
1 Like


I am also able to pass simple data types like string or int32 to UiPath but how about more sophisticated data structures like dictionaries or dataFrames? Any ideas?

Thx in advance

Hi Sebastian,

I think if you want to pass more complex structures you need to convert the data into something that python can interpret. For example converting a dictionary to json and then parsing the json in python, or even converting to csv and then parsing.

There’s a thread here: Invoke python method

No ideal but it’s the only way I know that will work.
Best regards


Hi Bob,

thx a lot for your answer! Actually, I want to pass data from python to UiPath to use the info there without having an intermediate step that involves saving the data somewhere. So I can convert the dataFrame to a JSON and set the dataType in UiPath in such a way that it expects a JSON, right? Do you think this might work?

Best regards,

Hi Sebastian,
I haven’t tried it but I’m feel confident that if in python you ‘write’ to json and then send that string to UiPath before converting to a JSON Object it will work.
My only doubt would be how long strings UiPath will accept as I have no idea what the limits are.


Hi Bob,

thx a lot! That actually did the trick! It works, I let the python script return a JSON-string with

return df.to_json(orient='records')

and read it in UiPath as a String in ‘Get Python Object’

and then parse this String using the ‘Deserialize JSON’-activity according to the info given in this thread: Convert json to Datatable - #4 by Florent_Salendres .
Now I have the data available in a dataTable. Great!

Thx again and cheers!