Check this example for a Windows project with VB language.
-
In the Studio machine install Python 3.10.10 64-bit from here https://www.python.org/ftp/python/3.10.10/python-3.10.10-amd64.exe . After installing it, you need to restart the machine.
-
In the Studio machine, for Windows projects, the Python Scope activity requires you to install the .NET Desktop Runtime 5.0.17. After installing it, you need to restart the machine.
-
In your project add the UiPath.Python.Activities[1.6.0] package.
-
Add a Python Scope activity and configure it as below (modify the values with your installation path):
Library path: "C:\Users\your_username\AppData\Local\Programs\Python\Python310\python310.dll"
Path: "C:\Users\your_username\AppData\Local\Programs\Python\Python310"
Target: x64
Version: Python >=3.10
- Create a python script with name MathOperations.py that will have this content:
def add(num1,num2):
return num1 + num2
def dif(num1,num2):
return num1 - num2
- Add a Load Python Script activity and configure it as below:
File: "MathOperations.py"
Result: pyScriptOut (create a variable with Ctrl + k)
- Add an Invoke Python Method activity and configure it as below:
InputParameters: Array.ConvertAll({5,4}, Function(x) CType(x, Object))
Instance: pyScriptOut
Name: "add"
Result: pyOutput (create a variable with Ctrl + k)
- Add a Get Python Object activity and configure it as below:
PythonOject: pyOutput
TypeArgument: Int32
Name: “add”
Result: addOperationOutput (create a variable with Ctrl + k)
- Add a Log Message activity and configure it as below:
LogLevel: LogLevel.Info
Message: addOperationOutput
- In the Variables panel check if the variables have the correct type:
- If you will run the file, the result will be 9.