How to install and execute Python script using the command prompt UiPath activities ?
Installation of Python
- Open the following URL - https://www.python.org/downloads/release/python-360/
- Download – WindowsX86 or x64 executable installer ( The version mentioned above supports both 32 and 64-bit Python )
- Click install and follow the steps [Python will be installed in the local app data]
- Running Python script from Command line, the script prints or returns "Hello World !!!" string.
Open Command Prompt
- Type 'Python' followed by script file name along with the full path to be executed as shown in below snippet
Running attached Python script from UiPath Studio
- Install the python activity package
- Add 'Python Scope' activity within the sequence.
- In 'Python Scope' properties - Provide the python installation path for the input parameter 'Path'.
- Add 'Load Python Script' activity with in 'Do' section of python scope.
- In 'Load Python Script' properties - Provide the full path to the script to be executed and create a variable to store output of the 'Load Python Script' activity.
- Add 'Invoke Python Method' activity with in 'Do' section of python scope under 'Load Python Script' activity.
- In 'Invoke Python Method' properties - Provide the 'Instance' which should be the output of 'Load Python Script' activity. Provide name of the function in 'Name' property. Create a variable to store output of the 'Invoke Python Method' activity.
- Add 'Get Python Object' activity with in 'Do' section of python scope under 'Invoke Python Method' activity.
- In 'Get Python Object' properties - Provide the 'Python Object' which should be the output of 'Invoke Python Method' activity. Create a variable to store output of the 'Get Python Object' activity.
- Add 'Write Line' activity with in 'Do' section of python scope under 'Get Python Object' activity.
- In 'Write Line' properties - Provide the 'Text' which should be the output of 'Get Python Object' activity and convert it to string using ToString method.
Full Sequence screenshot: