docs/user_guide/en/nodes/python.md
The Python node is used to execute Python scripts or inline code within workflows, implementing custom data processing, API calls, file operations, and other logic. Scripts are executed in the shared code_workspace/ directory and can access workflow context data.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
interpreter | string | No | Current Python | Python interpreter path |
args | list[str] | No | [] | Startup arguments appended to the interpreter |
env | dict[str, str] | No | {} | Additional environment variables, overrides system defaults |
timeout_seconds | int | No | 60 | Script execution timeout (seconds) |
encoding | string | No | utf-8 | Encoding for parsing stdout/stderr |
Python scripts are executed within the code_workspace/ directory:
nodes:
- id: Data Processor
type: python
config:
timeout_seconds: 120
env:
key: value
nodes:
- id: Script Runner
type: python
config:
interpreter: /usr/bin/python3.11
timeout_seconds: 300
encoding: utf-8
nodes:
- id: LLM Generator
type: agent
config:
provider: openai
name: gpt-4o
api_key: ${API_KEY}
role: You need to generate executable Python code based on user input. The code should be wrapped in ```python ```.
- id: Result Parser
type: python
config:
timeout_seconds: 30
edges:
- from: LLM Generator
to: Result Parser
code_workspace/ directorytimeout_secondsenv to pass additional environment variables, accessible in scripts via os.getenv