Python
Runs your own Python code inside a process and returns its result, its printed output and any error.
The Python action runs a piece of Python code that you write, as one step of your process. Use it for calculations, data clean-up or text processing that no ready-made action covers. The value your code returns becomes an output you can use in the next steps.
Add the action
In the Process Designer toolbox, open Scripting and pick Python (or type Python in the search box).

Inputs and outputs
| Field | Direction | Type | Required | What to put / what you get |
|---|---|---|---|---|
| Code | Input | Text (Python code) | Yes | Your Python code. Use return to send a value back to the process. |
| Timeout | Input | Integer | No | How many seconds the code may run, from 10 to 180. Default 60. |
| Single Result | Output | Any | No | The value your code returns, when it is not a list: a number, text, true/false or an object (a Python dict becomes a JSON object). |
| List Result | Output | List of any | No | The value your code returns, when it is a list. |
| Stdout | Output | Text | No | Everything your code printed with print(). |
| Error | Output | Text | No | The error message when your code fails or runs too long. Empty when the code worked. |
How your code is run
Your code runs as the body of a function:
return <value>ends the code and sends the value to Single Result, or to List Result when the value is a list. Only one of the two is filled.print()does not set a result. What you print goes to Stdout, which is useful for checking what your code did.- Code that ends without
returnleaves both results empty.
Examples
| Code | Output |
|---|---|
return 1 + 2 | Single Result 3 |
return [1, 2, 3] | List Result [1, 2, 3] |
return {"name": "Ana", "age": 30} | Single Result {"name": "Ana", "age": 30} |
print("Hello world") | Stdout Hello world, both results empty |
raise ValueError("bad value") | Error ValueError: bad value (line 1) |
You can define functions and call them:
def add(a, b):
return a + b
print('adding')
return add(2, 3)Result: Single Result 5, Stdout adding.
A library example:
import pandas as pd
return int(pd.Series([1, 2, 3]).sum())Result: Single Result 6.
Use process variables in the code
You can insert process variables into the code. Before the code runs, PROCESIO replaces each variable with its value, as plain text. So:
- a number variable can be used as it is:
total = <your number variable> * 2; - a text variable needs quotes around it in your code:
name = "<your text variable>".
Good to know
- A failing script does not stop the process. When your code raises an error or runs longer than Timeout, the step still finishes: Error holds the message (
TimeoutErrorfor a timeout) and both results are empty. Add a Decisional after the action that checks whether Error is empty. - The code runs in a sandbox. It cannot read or write files (
openis not available) and some modules cannot be imported, for exampleosorrequests; the error then saysimport of '…' is not allowed in this sandbox. To call a web API, use Call API or CURL and pass the response to the script. - Files: a script cannot take a file directly. Convert the file to text with File To Base64, pass the text to the script and decode it there with
base64. To create a file from a script, return Base64 text and convert it with Base64 To File. - Heavy libraries such as
pandastake a few seconds to load. Keep Timeout well above the time your code needs.
Available libraries
Besides the standard modules such as json, base64, math, re and datetime, these libraries are installed:
| Library | Import as |
|---|---|
| pandas | import pandas |
| NumPy | import numpy |
| SciPy | import scipy |
| Matplotlib | import matplotlib |
| Beautiful Soup | from bs4 import BeautifulSoup |
| PyPDF2 | import PyPDF2 |
| pdfplumber | import pdfplumber |
| spaCy | import spacy |
| staticmap | import staticmap |
| Pillow | from PIL import Image |
Python (Old) is the previous version of this action. It has a single Output instead of the separate result, Stdout and Error outputs. It still works in existing processes; use Python for new ones. See Actions to be decommissioned.

