Skip to main content

Execute Python Code

Executes Python code snippets or scripts. Before reaching for this, check get_expression_reference — most list filtering, dedup, sorting, pattern matching, and string manipulation can be done as a single {{ expression }}. RunPython is the right choice for stateful loops, external libraries (pandas, pymupdf), PDF span geometry, and anything that reads as 'a small program' rather than 'a transform'.

Category: Python Execution · Group: General · Activity name: RunPython

The RunPython activity in the designer

Example

outputVariable = RunPython("<code>", environment={}, interpreterPath="<interpreterPath>")

Inputs

NameTypeRequiredDefaultDescription
CodecodeYesThe Python code to be executed.
Environment VariablesobjectDefine environment variables for your Python script.
Interpreter PathstringThe path to the Python interpreter to be used for executing the code. This setting is only applicable on Windows systems.

Outputs

NameTypeDescription
outputVariablestringSpecifies the name of the variable that will store the execution result.