# Error : Invoke Python Method

**URL:** <https://forum.uipath.com/t/error-invoke-python-method/478565>\
**Category:** Community\
**Tags:** community, question, python, forum, activities\
**Created:** [October 6, 2022, 5:46am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565 "2022-10-06T05:46:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sukanya\_Dutta](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sukanya_dutta/32/319907_2.png) [@Sukanya\_Dutta](https://forum.uipath.com/u/Sukanya_Dutta)\
**Post date:** [October 6, 2022, 5:46am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/1 "2022-10-06T05:46:01Z")

</div>

Got this error in Invoke python method

 ![Untitled](https://global.discourse-cdn.com/uipath/original/4X/a/7/4/a7400fb921684bbd93d21f6c50f044be4a03ab32.png)

---

<div class="post-metadata">

**Author:** ![kennbalobalo](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kennbalobalo/32/20218_2.png) [@kennbalobalo](https://forum.uipath.com/u/kennbalobalo)\
**Post date:** [October 6, 2022, 5:48am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/2 "2022-10-06T05:48:33Z")

</div>

hi @Sukanya_Dutta

Appreciate if you can share the error message as well as the Python Code. thanks.

---

<div class="post-metadata">

**Author:** ![Sukanya\_Dutta](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sukanya_dutta/32/319907_2.png) [@Sukanya\_Dutta](https://forum.uipath.com/u/Sukanya_Dutta)\
**Post date:** [October 6, 2022, 5:50am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/3 "2022-10-06T05:50:02Z")

</div>

Error message → “Invoke python method : One or more errors occurred”

---

<div class="post-metadata">

**Author:** ![Adrian\_Brinas](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/adrian_brinas/32/318041_2.png) [@Adrian\_Brinas](https://forum.uipath.com/u/Adrian_Brinas)\
**Post date:** [October 6, 2022, 6:12am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/4 "2022-10-06T06:12:43Z")

</div>

Hello, from the available picture I can see the following problems:

- InputData of type DataTable is null
- InputString is null
- The type of InputString is Int32, maybe should be String
- The PyOutput pbject of type PythonObject is not initialized
- The Code property of the Python script is null

Please see first the following link, that may be useful:  
[Invoke Python Code UIPath](https://forum.uipath.com/t/step-to-invoke-python-code-in-uipath/162639)

Hope it can help. Adrian

---

<div class="post-metadata">

**Author:** ![Sukanya\_Dutta](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sukanya_dutta/32/319907_2.png) [@Sukanya\_Dutta](https://forum.uipath.com/u/Sukanya_Dutta)\
**Post date:** [October 6, 2022, 6:19am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/5 "2022-10-06T06:19:39Z")

</div>

How to solve this problem?

---

<div class="post-metadata">

**Author:** ![Rahul\_Unnikrishnan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahul_unnikrishnan/32/464046_2.png) [@Rahul\_Unnikrishnan](https://forum.uipath.com/u/Rahul_Unnikrishnan)\
**Post date:** [October 6, 2022, 6:39am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/6 "2022-10-06T06:39:26Z")

</div>

Hello @Sukanya_Dutta

Please check the below video.

[![](https://global.discourse-cdn.com/uipath/original/4X/8/f/2/8f2754f248ccc164ad10ae5632ddb6727b5aa89f.jpeg "How to Execute Python Scripts in UiPath?| UiPath Python Activities| Python Scope| Load Python Script") ](https://www.youtube.com/watch?v=ysyH37iF-8Q)

Thanks

---

<div class="post-metadata">

**Author:** ![Adrian\_Brinas](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/adrian_brinas/32/318041_2.png) [@Adrian\_Brinas](https://forum.uipath.com/u/Adrian_Brinas)\
**Post date:** [October 6, 2022, 1:48pm UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/7 "2022-10-06T13:48:51Z")

</div>

Hello again.  
Watching the tutorial, I see the Python Scope activity is important.  
So all the related Python activities must be included in this Scope.  
What can be more difficult, is to find the good working Python path.  
On my computer, I can get the next Library Path for my user name:

```auto
string.Format("{0}\AppData\Local\Programs\Python\Python37-32\python37.dll", 
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile))

```

So you don’t have to specify the full path to your user name.  
This path may depend also on the current installed Python version.  
A Python package must be installed prior to use any of the scripts.  
Personally, I have tried with more Python versions, 3.2 and 3.7.  
In Explorer I can open and edit a py file with an IDLE program.  
Running a script in IDLE, or other editors is a good verification.  
This ensures, that the script is correct, and doesn’t give errors.

Another common problem is how to pass the input arguments to script.  
Setting a variable in the Python Scope, this can become visible to the script.  
But a python script uses different techniques for passing input arguments.  
The Invoke Python Script activity should have a list of the input arguments.  
I also seen, from your picture, that you had built a list of input parameters.

I tried myself a script, that takes the path to a CSV file and reads it.  
For a list argument, could be more difficult to be declared in Python.  
Python is a programming language, having several specific syntax.  
Take a look, at how the function, conditions and loops are written.  
This script may look like this:

```auto
import sys
import csv
import os

def read_model(*args):
    pad = args[0]
    if (pad == ""): return
    if (not os.path.exists(pad)): return
    print(pad)
    csvfile = open(pad)
    reader = csv.reader(csvfile)
    for line in reader:
        print(line)
        str = line
    csvfile.close()
    return

read_model("./Model.csv")
#EOF

```

In my case, I didn’t have to use the Invoke Python Method.  
Because this method can be also called from inside the script.  
This read\_model function doesn’t return anything.

But usually, a function must return the result of a method.  
For other purpose, it needs maybe to return a sum of numbers.  
The out result is a variable of type: UIPath.Python.PythonObject  
For each variable you want to use, this must be declared first.  
This is made in Data Manager palette, or by Create New Variable.

Hope it can help. Adrian

---

<div class="post-metadata">

**Author:** ![hjina0412](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hjina0412/32/358921_2.png) [@hjina0412](https://forum.uipath.com/u/hjina0412)\
**Post date:** [June 21, 2023, 5:20am UTC](https://forum.uipath.com/t/error-invoke-python-method/478565/8 "2023-06-21T05:20:14Z")

</div>

I have a problem. Please share how to deal this problem.  
The error in “load python script activity” is: value cannot be null: parameter name: stream  
In python code, that have no error. But when it use Invoke Python Method, then have that error.  
Also, There was no error when working the loop to create ppt in python 6 times, but when working 36 times, the above error occurs.
