Python language needs no introduction today and with the growing no of machine learning & artificial intelligence use cases in the RPA industry, its is the obvious choice to integrate your workflow with Python.
Due to the huge no of libraries(modules and packages) available in Python its the first choice of language to perform such a task…One such example is Pandas – an amazing library which provides flexible and high-performance data structure manipulation and analysis tools.
Not this …there are many such libraries which provide a super quick way to perform your task such as Flask, NumPy, TensorFlow, Skit-learn etc.
Integration of cognitive use cases becomes easy with Python due to such machine learning, Computer vision, Artificial intelligence modules and a thousand examples available to support your idea.
Last week, I was working with OCR tools to integrate with uipath and then based on the result we were getting from the image… we decided to process the IMAGE using Computer Vision for Preprocessing & then tesseract to read data contained in the pdf.
After some initial hiccups in setting up Python Interpreter correctly, we were able to perform the task easily.
So I have documented the steps required for the Integration of Python … I hope this will help you…
Python Integration With UiPath: Getting Started
- Supported Python Interpreter (Not all Interpreters are being supported by UiPath at the moment such as 3.7 or 3.7 +)
- UiPath Python Activities Pack Must be added as Dependencies
- Notepad ++ / Pycharm (Or any Python Editor )- Optional to test script outside Uipath
How to Enable UiPath Python Activities Pack
To work with Python activities you need to first add UiPath Python Activities Pack as dependencies in your project.
You can enable and install the same from Manage Packages Window as shown below.
Once that is enabled …you will be able to see different activities of Python from search panel as below to test if they are successfully added.
So far so good…Let’s move to the steps required for integrating Python inside Uipath Workflow.
The UiPath.Python.Activities contain the following activities:
Using Python Activities in UiPath Studio
UiPath Studio provides a set of activities specifically designed for Python integration. These activities enable users to execute Python scripts and interact with Python objects seamlessly. Here are some key activities available in UiPath Studio for Python integration:
- Invoke Python Method: This activity allows you to invoke a specific method from a Python script within your UiPath workflow. It supports passing input parameters and receiving output values from the Python script.
- Load Python Script: With this activity, you can load an external Python script into your UiPath workflow and execute it. This enables you to leverage existing Python code and integrate it into your automation process.
- Get Python Object: This activity retrieves a Python object from a specified variable. It enables you to work with Python objects seamlessly within your UiPath workflow.
- Invoke Python Code: This activity provides a flexible way to execute Python code directly within your UiPath workflow. It is useful for performing quick calculations or executing small code snippets without the need for separate Python scripts.
By leveraging these activities, developers can seamlessly integrate Python scripts and code snippets into their UiPath automation workflows, unlocking the full potential of Python’s capabilities.
Read More at Uipath Documentation – https://docs.uipath.com/releasenotes/docs/uipath-python-activities
For this example, we are going to write a small Python program which will calculate the sum of the first N(Numbers Passed as Argument) and display the result in the output window. Let’s say the Python program is saved as “test.py”
# Return the sum of square of first n natural numbers
def squaresum(n):
sm = 0
for i in range(1, n + 1):
sm = sm + (i * i)
return sm
Our final workflow will look like this…
STEP 1- Drag Python Scope into your workflow window and set the following properties.
- Python Path – This should be the location where your Python interpreter is installed, You should give the path at the Directory level. For my example its – C:\Users\XXXX\AppData\Local\Programs\Python\Python36 (Make sure to change accordingly)
- Target – Did you install a 64-bit variant or 32-bit variant of Python (In my case its x64)
- Version – This is important as not all the Python variants can be integrated with the Uipath so you should go with the available list only for example you won’t find Python 3.7 + as of now
STEP 2 – Load Python Script
- In this step, you need to either enter code in the properties panel if small block or you should load an external Python file here(for my example it is test.py is kept inside the data folder)
- You need to create a python Object as Result output which will be used for further processing(In my example I have created a variable of python object type as sum square ), You can give any name
STEP 3- Invoke Python Method
This is the most important step in Python integration part –
- Input Argument – You need to pass the argument to your Python method here, So you need to make sure that arguments are matched with the program you have written. As of now, there is no support for named tuple and you need to provide your inputs as a dictionary as {arg1, arg2}. For my example, the input is {Number} as I have created a Number variable to pass as an Input Argument
- Instance – You also need to recall your Python Instance Variable which you created in the previous step to be passed here. This is useful in case you need to invoke multiple Python scripts so that the required instance of the object is referred. For my example python object is sum square
- Name – Name is the Name of the method inside your Python program which needs to be called. Make sure to pass them inside ” ” as this is String – Name of the method to be invoked
- Output – You need to store the result of the executed method into some Python object which can be used for further processing. For my example, we have created a variable as SumPythonObject to store the result.
STEP 4 – Get Python Object
In this step the result variable we have created in the previous step need to be converted into .NET type object so that they can be used into Uipath , Here we simple provide name of Variable we wish to convert into and Type of object.
PS- Some time you need to be careful here as all type of python objects cant be converted into .NET objects, You need to make sure types are compatible.
Once .NET object Variable is ready you can use with as usual to work in Uipath. For my example, SumUipathObject is the variable name which is converted from SumPythonObject variable.
Python Integration With UiPath: A Match Made in Automation Heaven
What is Python Integration With UiPath?
Python integration with UiPath refers to the ability to leverage Python’s capabilities within the UiPath RPA platform. It allows developers to harness the extensive libraries and frameworks available in Python to enhance the functionality and flexibility of automation workflows. By integrating Python scripts and code snippets into UiPath, users can perform complex data manipulations, interact with external systems, and unlock advanced analytical capabilities.
Benefits of Python Integration With UiPath
- Expanded Functionality: Python integration extends the capabilities of UiPath by leveraging the vast ecosystem of Python libraries. This opens up a world of possibilities for automation, including advanced data processing, machine learning, natural language processing, and more.
- Simplified Automation: Python’s simple syntax and extensive libraries make it easier to automate complex tasks within UiPath. Developers can leverage pre-built Python code snippets or create their own custom scripts to tackle specific automation challenges efficiently.
- Enhanced Data Manipulation: Python’s data manipulation libraries, such as Pandas and NumPy, provide powerful tools for handling and analyzing structured and unstructured data. By integrating Python with UiPath, organizations can leverage these libraries to extract insights and make data-driven decisions.
- Machine Learning Capabilities: Python is widely recognized as the go-to language for machine learning. By integrating Python’s machine learning libraries, such as TensorFlow and Scikit-learn, with UiPath, businesses can automate predictive analysis, anomaly detection, and other machine learning tasks.
- Community Support and Resources: Both UiPath and Python have thriving communities with extensive documentation, forums, and online resources. This abundance of support ensures that users can find help and solutions to their integration challenges quickly.
Some Common Issues you might face when you integrate Python with Uipath
- UiPath Python Host32 has stopped working- Unfortunately, the best I can say is to re-re-check your environment, as I believe the correct Anaconda installation or Python interpreter is NOT being referenced. which causes this issue. Also at the moment, no support is available for Python 3.7 + so you need to ensure that you are using supported python variant.
- UiPath Robot has stopped working – You also might face UiPath Robot has stopped working, It may be due to any reason and hence it requires multiple steps to ensure you are nothing wrong with environment setup, So Run DiagTool using below step and go through the logs to see what went wrong –
- Open the UiPath Robot installation folder: %localappdata%\UiPath\app-18.1.3
- Open a Powershell or CommandPrompt window
.\UiPath.DiagTool.exe -f crash_report.zip
- Then you can find the report file on your desktop.
- Few Other Known issues are described here –
Frequently Asked Questions (FAQs)
FAQ 1: Can I use Python libraries in UiPath?
Yes, Python integration with UiPath allows you to leverage Python libraries seamlessly within your automation workflows. You can import and use popular libraries like Pandas, NumPy, TensorFlow, Scikit-learn, and many others to enhance the functionality of your automation processes.
FAQ 2: Do I need to be an expert in Python to integrate it with UiPath?
While having a good understanding of Python can be beneficial, you don’t necessarily need to be an expert in Python to integrate it with UiPath. UiPath provides user-friendly activities that abstract the complexity of Python integration, making it accessible to users with varying levels of Python proficiency.
FAQ 3: Can I pass data between UiPath and Python scripts?
Absolutely! UiPath allows seamless data exchange between UiPath workflows and Python scripts. You can pass input parameters to Python scripts from UiPath and retrieve output values generated by the Python scripts back into UiPath for further processing.
FAQ 4: Are there any limitations or compatibility issues when integrating Python with UiPath?
UiPath provides robust support for Python integration, and compatibility issues are minimal. However, it is essential to ensure that the versions of Python and the Python libraries you are using are compatible with the UiPath Python Activities package. Refer to the UiPath documentation for the recommended versions and compatibility guidelines.
FAQ 5: Can I deploy automation workflows integrating Python with UiPath in a production environment?
Yes, automation workflows that integrate Python with UiPath can be deployed in production environments. UiPath provides enterprise-grade features like centralized orchestration, security, and scalability, ensuring that your integrated automation workflows can be seamlessly deployed and managed in production settings.
FAQ 6: Where can I find resources and support for Python integration with UiPath?
Both UiPath and Python have extensive communities and official documentation. You can visit the UiPath Forum, UiPath Academy, and the Python community websites for tutorials, examples, and solutions to integration-related queries. Additionally, UiPath provides comprehensive documentation on Python integration, which serves as an excellent resource for getting started and troubleshooting.
Conclusion
Python integration with UiPath unlocks a new realm of automation possibilities. By combining the power of Python’s extensive libraries and frameworks with UiPath’s robust automation capabilities, organizations can streamline their operations, enhance productivity, and make data-driven decisions. Whether you are looking to perform advanced data manipulations, leverage machine learning capabilities, or interact with external systems, Python integration with UiPath empowers you to achieve automation excellence.
So, embrace the synergy of Python and UiPath, and embark on a journey towards more efficient and intelligent automation
Please feel free to reach me in case you are still facing any issues with your Python integration with Uipath.
Happy Automation!
How we can Covert RPA code written using UiPath to python.
Mainly how we can develop an RPA using python .
Please guide.
https://www.ultimatesuite.com/rpa
Hi Satish , in my project I added the path as you described at both in the dictionary variable and on the assets – I still get “ python exe not found error”. . Please help me with your thought.
You might have multiple pythons installed on your machine. Please check and update the path accordingly. also check 32bit vs 64bit
Invoke Python Method: One or more errors occurred. getting this error in invoke method i have passed Number