Passing arguments to Python

@bobpeers pls send any sample file passing list object to python method

@bobpeers
pythonD1 pythonD2 PythonD3 pythonD4 tolearnPy.zip (15.5 KB)

Hi, I’m trying to pass a file path as a parameter to the python script in invoke python method. But it says error invoking python method.
Any help is appreciated. Thank you

Hi @sandhya.b

Welcome to our UiPath Forum! :slight_smile:

Maybe this tutorial will help you:

It contains a very simple guide with screenshots and steps to follow on how to use Python scripting in UiPath Studio :slight_smile:

2 Likes

Thank you so much for the response…:blush:

1 Like

Subject : function with multiple parameters are not getting executed through python scope whereas when i use the same function in IDLE it is working perfectly fine.

from the above post,
Point 1) i need to add import sys; package
Point 2) how to pass the parameter for my fucntion which involves all three parameters(two path and one string)

Function Name : ExtractHtml, PFB the function input parameters

print(
ExtractHtml(“\\deda1vfiler13\RPA_DEVELOPMENT\DevGov\Bot\Data\Input\Batch-25-09-2022\Batch-08-59-48\InputfilePOCFinal_Copy - Copy.docx”,
“143”,
“\\deda1vfiler13\RPA_DEVELOPMENT\DevGov\Bot\Data\Temp\Batch-25-09-2022\Batch-08-59-48”)
)

Please help on this!

Hello @soundappan.prabu
As you have mentioned its working in IDE, can you please confirm you have passed the arguments to the python script in uipath?

Also please share the error if any.

Thanks

No, through python IDLE only! A simple function working fine with python scope of UIpath! when passing one than one parameter then the problem rises.!

20.10.6+Branch.master.Sha.37657ef79003ea8751ac4efb35736eeeace8b2ce

Source: Invoke Python Method

Message: One or more errors occurred.

Exception Type: System.AggregateException

RemoteException wrapping System.AggregateException: One or more errors occurred. —> RemoteException wrapping System.InvalidOperationException: Error invoking Python method —> RemoteException wrapping System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: com_error : (-2147352567, ‘Exception occurred.’, (0, ‘Microsoft Word’, ‘Sorry, we couldn't find your file. Was it moved, renamed, or deleted?\r (“C:\…\InputfilePOCFinal_Copy - Cop…”)’, ‘wdmain11.chm’, 24654, -2146823114), None)

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at UiPath.Python.Service.IPythonService.InvokeMethod(Guid instance, String method, IEnumerable1 args) at UiPath.Python.Impl.OutOfProcessEngine.<>c__DisplayClass14_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)

Hi,

How do i pass this as arguments in studio, could you please help?

from translate import Translator
#from googletrans import Translator

def languageTranslator(userData):
translator= Translator(from_lang=“bulgarian”, to_lang=userData.get(‘language’))
translatedText= translator.translate(userData.get(‘text’))
#print("rsult: " + translatedText)
return(translatedText)