Help!- Error in Invoke python Method

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)

The Python Code Code:

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.

@copy_writes

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

Cheers

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,
IEnumerable1 args) at UiPath.Python.Impl.OutOfProcessEngine.<>c__DisplayClass15_0.<InvokeMethod>b__0() at System.Threading.Tasks.Task1.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)

@copy_writes

looks like .net runtime issue…try to install.net runtime 5+

to confirm check the event viewer panel when the error occurs

cheers

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)?

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.Task1.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, IEnumerable1 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()

@copy_writes

As per error one of required argument is missing

cheers

OK What is the step I need to take can you guide me I send you the code
Document Understanding (2).zip (2.4 MB)

@copy_writes

check thsi

cheers

I assigned the value in the code.

also I check teh .net version its updated one