Overview
This node executes arbitrary Python code inside an isolated environment managed by Micromamba, a lightweight package manager. It allows users to specify the exact Python version and any pip-style package requirements, runs the provided Python script, and returns the standard output of that script.
Common scenarios where this node is beneficial include:
- Running custom Python scripts that require specific Python versions or dependencies without affecting the host system.
- Testing or prototyping Python code snippets within an n8n workflow.
- Automating data processing or analysis tasks using Python libraries installed on demand.
For example, you could use this node to run a Python script that processes JSON input, uses pandas for data manipulation (installed via requirements), and outputs results back into the workflow.
Properties
| Name | Meaning |
|---|---|
| Python Version | Exact Python version string to use, e.g., "3.9", "3.10.14", "3.11". |
| Requirements | List of pip-style package requirements, one per line, to install in the environment. |
| Python Code | The Python source code to execute; the node returns its standard output (stdout). |
| Keep Environment | Boolean flag indicating whether to keep the created Micromamba environment after execution. |
Output
The node outputs a single JSON object with one field:
output: A string containing the trimmed standard output (stdout) produced by the executed Python script.
No binary data output is produced by this node.
Example output JSON structure:
{
"output": "Result from the Python script"
}
Dependencies
- Micromamba: The node requires Micromamba to create isolated Python environments dynamically. If Micromamba is not found on the system, the node attempts to download and install it automatically.
- Python: The specified Python version must be available via Micromamba.
- pip packages: Any packages listed in the "Requirements" property are installed inside the created environment before running the script.
- System utilities: The node uses shell commands like
wget,tar, andrmfor managing Micromamba installation and environment cleanup.
No additional n8n credentials or environment variables are required.
Troubleshooting
- Micromamba not found or failed to install: The node tries to install Micromamba if missing, but this requires network access and certain system utilities (
wget,tar). Ensure these are available and accessible. - Python version unavailable: Specifying a Python version not supported by Micromamba will cause environment creation to fail. Use valid version strings.
- Package installation errors: Invalid or conflicting package requirements can cause pip install failures. Verify the requirements syntax and compatibility.
- Script execution errors: Errors in the Python code itself will propagate as node operation errors. Check your Python code for syntax or runtime issues.
- Large output buffer exceeded: The node sets a max buffer size for stdout (10 MB). Extremely large outputs may cause errors.
- Environment cleanup: If "Keep Environment" is false, the environment is deleted after execution. If set true, environments accumulate and consume disk space.