Actions2
Overview
This node allows you to execute Python scripts using the system's Python runtime environment. It supports two main operations: running a Python script file or executing inline Python code directly. This is useful for automating tasks, data processing, or integrating Python logic within an n8n workflow without needing a separate Python environment setup inside n8n.
A common scenario is running existing Python scripts stored on your system with optional command-line arguments. For example, you might run a data analysis script and capture its output for further processing in your workflow.
Properties
| Name | Meaning |
|---|---|
| File Path | The full path to the Python script file you want to execute (required for "Run File"). |
| Command Arguments | Optional string of arguments to pass to the Python script when executed. |
| Python Path | Path to the Python executable to use (defaults to python3). Useful if multiple versions are installed. |
Output
The node outputs JSON objects containing the following fields:
stdout: The trimmed standard output from the Python script execution.stderr: The trimmed standard error output from the Python script execution.success: A boolean indicating whether the script ran successfully (true) or failed (false).error: Present only if the execution failed; contains the error message.
No binary data is produced by this node.
Example output JSON:
{
"stdout": "Hello from Python!",
"stderr": "",
"success": true
}
Dependencies
- Requires access to a system Python runtime executable (default
python3). - No external API keys or services are needed.
- The node uses Node.js child process utilities to spawn Python processes.
Troubleshooting
Common issues:
- Incorrect file path: Ensure the specified Python script file exists and the path is correct.
- Python executable not found: If the default
python3is not available, specify the correct path in the "Python Path" property. - Script errors: Any Python exceptions or syntax errors will appear in the
stderroutput.
Error messages:
- If the node fails to execute the script, it returns an error message in the output's
errorfield along with any capturedstdoutandstderr. - To continue workflow execution despite errors, enable the node's "Continue On Fail" option.
- If the node fails to execute the script, it returns an error message in the output's