# Help!- Error in Invoke python Method

**URL:** <https://forum.uipath.com/t/help-error-in-invoke-python-method/701333>\
**Category:** Studio\
**Tags:** question, studio, python, activities\
**Created:** [November 21, 2023, 10:48am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333 "2023-11-21T10:48:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![copy\_writes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/copy_writes/32/183191_2.png) [@copy\_writes](https://forum.uipath.com/u/copy_writes)\
**Post date:** [November 21, 2023, 10:48am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/1 "2023-11-21T10:48:54Z")

</div>

Hi Team,

I am Interacting Python with UiPath I am getting the below error While running.

Error:  
**Invoke Python Method: One or more errors occurred. (Error invoking Python method)**

 ![image](https://global.discourse-cdn.com/uipath/original/4X/8/7/d/87d8896bc4022f4cfa67bd29ebd4817471a3c5fa.png)

The Python Code Code:

```auto
import cv2
import os

def capture_images(destination_folder):
    # Initialize camera
    cap = cv2.VideoCapture(0) # 0 represents the default camera

    # Create destination folder if it doesn't exist
    if not os.path.exists(destination_folder):
        os.makedirs(destination_folder)

    image_count = 0

    while True:
        # Capture frame from the camera
        ret, frame = cap.read()

        # Display the frame
        cv2.imshow('Camera', frame)

        # Check for user input (press 'q' to quit)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

        # Capture images (press 's' to save)
        if cv2.waitKey(1) & 0xFF == ord('s'):
            image_count += 1
            image_path = os.path.join(destination_folder, f'image_{image_count}.png')
            cv2.imwrite(image_path, frame)
            print(f'Image {image_count} captured and saved.')

    # Release the camera and close windows
    cap.release()
    cv2.destroyAllWindows()

    # Print success message
    print('Scan Complete. Images captured and saved successfully.')

if __name__ == " __main__":
    destination_folder = r"C:\Users\admin\Documents\UiPath\Document Understanding\Destination Folder"
    capture_images(destination_folder)

```

**Note:** It runs as expected in VS Code but when I try to integrate with UiPath I get an error.

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [November 23, 2023, 4:53am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/2 "2023-11-23T04:53:51Z")

</div>

@copy_writes

Please open the locals pnale and check you would see the exception detils properly there

Cheers

---

<div class="post-metadata">

**Author:** ![copy\_writes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/copy_writes/32/183191_2.png) [@copy\_writes](https://forum.uipath.com/u/copy_writes)\
**Post date:** [November 23, 2023, 7:08am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/3 "2023-11-23T07:08:39Z")

</div>

**Error I am geeting the loacal panal:**

RemoteException wrapping System.AggregateException: One or more errors occurred. (Error invoking Python method) —\> RemoteException wrapping System.InvalidOperationException: Error invoking Python method —\> RemoteException wrapping System.IO.IOException: Pipe is broken.  
at System.IO.Pipes.PipeStream.CheckWriteOperations()  
at System.IO.Pipes.PipeStream.Flush()  
at System.IO.StreamWriter.Flush(Boolean flushStream,  
Boolean flushEncoder)  
at System.IO.StreamWriter.Dispose(Boolean disposing)  
at System.IO.TextWriter.Dispose()  
at UiPath.Python.Service.PythonProxy.RequestAsync(PythonRequest request,  
CancellationToken ct)  
at UiPath.Python.Service.PythonProxy.InvokeMethod(Guid instance,  
String method,  
IEnumerable`1 args) at UiPath.Python.Impl.OutOfProcessEngine.<>c __DisplayClass15_0.<InvokeMethod>b__ 0() at System.Threading.Tasks.Task`1.InnerInvoke()  
at System.Threading.Tasks.Task.\<\>c.\<.cctor\>b\_\_272\_0(Object obj)  
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread,  
ExecutionContext executionContext,  
ContextCallback callback,  
Object state)  
— End of stack trace from previous location —  
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread,  
ExecutionContext executionContext,  
ContextCallback callback,  
Object state)  
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot,  
Thread threadPoolThread)  
— End of stack trace from previous location —  
at UiPath.Python.Activities.InvokeMethod.ExecuteAsync(AsyncCodeActivityContext context,  
CancellationToken cancellationToken)  
— End of inner exception stack trace —  
at UiPath.Python.Activities.InvokeMethod.ExecuteAsync(AsyncCodeActivityContext context,  
CancellationToken cancellationToken)  
— End of inner exception stack trace —  
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context,  
IAsyncResult result)  
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context,  
IAsyncResult result)  
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor,  
BookmarkManager bookmarkManager)

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [November 23, 2023, 7:17am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/4 "2023-11-23T07:17:20Z")

</div>

@copy_writes

looks like .net runtime issue…try to [install.net](http://install.net) runtime 5+

to confirm check the event viewer panel when the error occurs

cheers

---

<div class="post-metadata">

**Author:** ![copy\_writes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/copy_writes/32/183191_2.png) [@copy\_writes](https://forum.uipath.com/u/copy_writes)\
**Post date:** [November 23, 2023, 7:29am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/5 "2023-11-23T07:29:56Z")

</div>

means you are talking about need to install the .net 5 to my system?  
My Question Is  
1 What is runtime 5+  
2 what is the version I need to install(.net)?

---

<div class="post-metadata">

**Author:** ![copy\_writes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/copy_writes/32/183191_2.png) [@copy\_writes](https://forum.uipath.com/u/copy_writes)\
**Post date:** [November 23, 2023, 7:56am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/6 "2023-11-23T07:56:09Z")

</div>

I got the below error  
function Toggle(node) { if (!window.fullyLoaded) return; var divNode = node.nextElementSibling; // nextElementSibling may unexpectedly return null if (!divNode) divNode = node.nextSibling; if (!divNode || divNode.nodeType != 1) return; // Expand the branch? if (divNode.style.display == ‘none’) { // Change the sign to “-”. var bNode = node.getElementsByTagName(“b”)[0]; bNode.innerText = “-”; // show the branch divNode.style.display = ‘’; } else // Collapse the branch { // Change the sign to “+”. var bNode = node.getElementsByTagName(“b”)[0]; bNode.innerText = “+”; // hide the branch divNode.style.display = ‘none’; } } // Toggle “System” element by default so that its default status is to hide its children function ToggleSystemElement() { var body = document.getElementById(“body”); var anchor = body.getElementsByTagName(“table”)[0]; Toggle(anchor); } // If binary data is present in event XML, show it in friendly form. function ProcessBinaryData(binaryString, binaryDataCaption, wordsFormatString, bytesFormatString, normalFont, fixedWidthFont) { var bodyNode = document.getElementById(“body”); // Add a

* * *
 at the end of the HTML body. bodyNode.appendChild(document.createElement(“hr”)); // This paragraph (p element) is the “Binary data:” literal string. var p = document.createElement(“p”); p.style.fontFamily = normalFont; var b = document.createElement(“b”); b.appendChild(document.createTextNode(binaryDataCaption)); p.appendChild(b); p.appendChild(document.createElement(“br”)); bodyNode.appendChild(p); // // Show binary data in Words format. // p = document.createElement(“p”); p.style.fontFamily = normalFont; p.appendChild(document.createTextNode(wordsFormatString)); bodyNode.appendChild(p); // Must use fixed-width font for binary data. p = document.createElement(“p”); p.style.fontFamily = fixedWidthFont; var i = 0; var j = 0; var s, tempS; var translatedString; var charCode; var byte1, byte2; // Each character in binaryString is a hex (16-based) representation of // 4 binary bits. So it takes 2 characters in binaryString to form a // complete byte; 4 characters for a word. while (i \< binaryString.length) { s = (i / 2).toString(16); // To hex representation. while (s.length \< 4) { s = “0” + s; } s += ": "; // DWords representation is simply a rearrangement of the original binaryString // For example, from: // // 0000000002005600000000000f000540 // // (which is 00 00 00 00 02 00 56 00 00 00 00 00 0f 00 05 40). // // to: // // 0000: 00000000 00560002 00000000 4005000f // 8 words per line, 4 DWords per line. for (j = 0; j \< 4; j++) { s += binaryString.substring(i + 6, i + 8); s += binaryString.substring(i + 4, i + 6); s += binaryString.substring(i + 2, i + 4); s += binaryString.substring(i, i + 2) + " "; i += 8; } p.appendChild(document.createTextNode(s)); p.appendChild(document.createElement(“br”)); } bodyNode.appendChild(p); // // Show binary data in bytes format. // p = document.createElement(“p”); p.style.fontFamily = normalFont; p.appendChild(document.createTextNode(bytesFormatString)); bodyNode.appendChild(p); // Must use fixed-width font for binary data. p = document.createElement(“p”); p.style.fontFamily = fixedWidthFont; i = 0; j = 0; // Each character in binaryString is a hex (16-based) representation of // 4 binary bits. So it takes 2 characters in binaryString to form a // complete byte. while (i \< binaryString.length) { translatedString = “”; // 2 characters in binaryString to form a byte s = (i / 2).toString(16); // to hex representation. // Prefix with ‘0’ until its length is 4. while (s.length \< 4) { s = “0” + s; } s += ": "; // Show 8 bytes per line for (j = 0; j \< 8; j++) { tempS = binaryString.substring(i, i + 2); // 2 for 1 byte i += 2; s += tempS + " "; // Treat tempS as hex integer charCode = parseInt(tempS, 16); if (charCode \< 32) { translatedString += “.”; } else { translatedString += String.fromCharCode(charCode); } } while (s.length \< 32) { s += " "; } s += translatedString; p.appendChild(document.createTextNode(s)); p.appendChild(document.createElement(“br”)); } bodyNode.appendChild(p); }

Application: UiPath.Python.Host.exe CoreCLR Version: 5.0.1722.21314 .NET Version: 5.0.17 Description: The process was terminated due to an unhandled exception. Exception Info: Python.Runtime.PythonException: capture\_images() missing 1 required positional argument: ‘destination\_folder’ at Python.Runtime.PythonException.ThrowLastAsClrException() at Python.Runtime.PyObject.Invoke(PyObject args) at Python.Runtime.PyObject.InvokeMethod(String name, PyObject args) — End of stack trace from previous location — at UiPath.Python.Impl.Engine.\<\>c\_\_DisplayClass31\_0.b\_\_0() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at UiPath.Python.Host.PythonService.InvokeMethod(Guid instance, String method, IEnumerable`1 args) at UiPath.Python.Host.PythonService.RunServer() at System.Threading.Tasks.Task.\<\>c.b\_\_140\_1(Object state) at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.\_ThreadPoolWaitCallback.PerformWaitCallback()

> [@Anil\_G](#):
>
> to confirm check the event viewer panel when the error occurs

 ![image](https://global.discourse-cdn.com/uipath/original/4X/5/8/e/58e6b5a50acb68344f1aad5d0f3a64273d3077da.png)

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [November 23, 2023, 8:17am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/7 "2023-11-23T08:17:01Z")

</div>

@copy_writes

> **[Download .NET 5.0 (Linux, macOS, and Windows)](https://dotnet.microsoft.com/en-us/download/dotnet/5.0)**
>
> .NET 5.0 downloads for Linux, macOS, and Windows. .NET is a free, cross-platform, open-source developer platform for building many different types of applications.

As per error one of required argument is missing

cheers

---

<div class="post-metadata">

**Author:** ![copy\_writes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/copy_writes/32/183191_2.png) [@copy\_writes](https://forum.uipath.com/u/copy_writes)\
**Post date:** [November 23, 2023, 9:21am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/8 "2023-11-23T09:21:43Z")

</div>

> [@Anil\_G](#):
>
> As per error one of required argument is missing

OK What is the step I need to take can you guide me I send you the code  
[Document Understanding (2).zip](https://forum.uipath.com/uploads/short-url/wuKPDkrBfDZuoiB2OZso0VGcbc3.zip) (2.4 MB)

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [November 23, 2023, 9:44am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/9 "2023-11-23T09:44:41Z")

</div>

> [@copy\_writes](#):
>
> missing 1 required positional argument: ‘destination\_folder’

@copy_writes

check thsi

cheers

---

<div class="post-metadata">

**Author:** ![copy\_writes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/copy_writes/32/183191_2.png) [@copy\_writes](https://forum.uipath.com/u/copy_writes)\
**Post date:** [November 23, 2023, 9:58am UTC](https://forum.uipath.com/t/help-error-in-invoke-python-method/701333/10 "2023-11-23T09:58:37Z")

</div>

> [@copy\_writes](#):
>
> ` destination_folder = r"C:\Users\admin\Documents\UiPath\Document Understanding\Destination Folder"`

I assigned the value in the code.

also I check teh .net version its updated one

 ![image](https://global.discourse-cdn.com/uipath/original/4X/6/d/5/6d5ec667a4d516382f6f673c0a759679dd96e9c4.png)
