Python

The Python task allows for the running of Python scripts using an environment available on a host that has the Loome Integrate Agent installed. The Python script can be entered in the Loome Integrate application, with the execution handled by the native python installation on the host PC.

How to Set Up a Python Environment

If you do not have a Python environment, you can download Python using the following guide.

Follow the next section if you already have a Python environment to learn how it can be used in Loome Integrate.

Step 1. Download an Installer

Go to https://www.python.org/downloads/windows/ and find the installer for the version you want to download.

For this example, we are using Python 3.7 shown in the following image.

Installer

Step 2. Run the Installer

Run the installer and make sure that ‘Add Python 3.7 to PATH’ is unchecked (as the image below).

Then select Customize Installation.

Uncheck 'Add Python 3.7 to PATH' and select 'Customize Installation'.

Select all optional features.

All optional features

On the next page, take note of the Customize Install Location value. You can change this location but make sure to remember and note where you install it, as it will be needed for your environment later.

Step 3. Complete the Installation

Once the installer has run successfully, you will be able to create an environment at the install location selected in the above step.

Working with Python Environments in Loome Integrate

Python tasks require at least one Python Environment to be configured for the agent you want to run the Python script on.

Python Environments point to the location on the agent’s host where the Python installation you wish to use is located, in most cases this is the default installation of Python depending on your operating system.

How to Set up a Python Environment

To add a Python environment, on the Agent page, select the settings button for the agent that has the Python installation located on its host.

Agent Settings button

On the left you will see a Python Environments tab, in this tab you can easily add and remove Python Environments for that agent.

Python environment settings

Add a name for your environment, and provide the file path for its location. The path is where the Python setup was installed.

Click on Add Environment and you can now use your Python environment in Loome Integrate.

Requirements

The executable for the Python environment must be named python or python3 to be compatible with Loome Integrate Online.

If using an Agent Docker image, Python 3 is installed in /usr/bin

The location of a Python environment is the path to the folder that contains the python executable. This can be usually found with Powershell using [System.IO.Path]::GetDirectoryName((Get-Command python).Source) and with bash using whereis python.

To learn how to use a File Connection as your Script Source to execute a script from a file in your Git Repository, please read more here.

How to Create a Python Task

When creating a task, select Python, and the agent that has the Python environment we added above.

Python task

On the next page, you can then add your script for Python or select a file from a Git Repository.

Add your Python script

Select your Python environment from the dropdown.

Submit this task and you can now run your Python script.