Need help in executing python script by passing file location as arguments saved in variables

My objective is to run a python script which inserts an jpeg image in a ppt file using UiPath.
Python code is
def UseCase(image,text1,location):
# sav = location.replace(“",”/“)
# pic = image.replace(”",“/”)
sav = (r’{}‘.format(location))
pic = (r’{}'.format(image))
t1 = text1
prs = Presentation(r"E:\UiPath\Template\ppt_template.pptx")
slide = prs.slides.add_slide(prs.slide_layouts[11])
placeholder = slide.placeholders[10]
picture = placeholder.insert_picture(pic)
title = slide.shapes.title
title.text = t1
prs.save(sav)

Issue- The image location and the location to save the ppt are available as variable in UiPath and I have to paas those variables in as arguments for the above function but no matter what I do it it returns the error “Invoke python method” one or more error occured. and there is no explanation about what error occured. Can anyone please help me with this issue please

Hi @nitesh.chouhan24

Print what you are passing may be something is wrong.

Second try giving try catch in python and have a result so that may be if python is failing it might be caught and given as a output

Also check inner exception details in locals panel which might give some info about what happened

Cheers

1 Like

Im passing three arguments
img- location of image to be inserted
file- a string
pptchart- location of ppt to be saved
the python code works fine when checked in interpreter. The error in UiPath does not explain about the error. it just says one or more error occurred. I have been stuck on this for few days now.
I tried writing the code directly in “Invoke python activity” but not able to figure out how to pass the variables as parameters in code, so decided to call the function and paas the variables as parameters. Could not make either of the method work.

Error details are as follows now-
RemoteException wrapping System.AggregateException: One or more errors occurred. —> 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.Execute()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Python.Activities.InvokeMethod.d__16.MoveNext()
— End of inner exception stack trace —
at UiPath.Python.Activities.InvokeMethod.d__16.MoveNext()
— 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)