Actions132
- AI Actions
- Extract Text From Document
- Check Content Policy
- Detect Adult Content
- Detect Brand
- Detect Color
- Detect Email Type
- Detect Faces
- Extract Entities
- Extract Contact Information
- Extract Customizable Information From Text
- Fuzzy Text Matcher
- Generate Image
- Generate JavaScript Code
- Generate Python Code
- Detect Language
- Detect Mood
- Extract Text From PDF
- Recognize Objects in Image
- Extract Text From Image
- Redact Sensitive Information From PDF
- Remove Background Image
- Summarize Text
- Transcribe
- Translate Text
- Image Actions
- Business Actions
- Convert Actions
- Generate Actions
- Crypto Actions
- Operator Actions
- Storage Actions
- Scheduler Actions
- Text Actions
- Chart Actions
- Code Actions
- Calculate Actions
- Date and Time Actions
- PDF Actions
- Compress PDF File
- Count PDF Pages
- Create Empty PDF
- Decrypt PDF
- Convert DOCX to PDF
- Draw Image on PDF
- Draw Text on PDF
- Encrypt PDF
- Convert HTML to PDF
- Convert Markdown to PDF
- Manage PDF Metadata
- Merge PDF Files
- Add PDF Pages
- Remove PDF Pages
- Resize PDF Pages
- Rotate PDF Pages
- Convert PDF to Base64
- Convert PDF to Image
- Split PDF File
- Add Image Watermark to PDF
- Add Text Watermark to PDF
- Shortened URL Actions
Code → Python B2
AI-generatedOverview
The node provides a way to execute custom Python code snippets within an n8n workflow using a backend service. It is designed for scenarios where users want to run arbitrary Python scripts, potentially with external dependencies, and get the output as JSON. This can be useful for data processing, automation tasks, or integrating Python-based logic that is not natively supported in n8n.
For example, you might use this node to:
- Run a Python script that processes input data and returns transformed results.
- Execute machine learning inference code by importing required libraries.
- Perform complex calculations or data manipulations that are easier in Python.
Properties
| Name | Meaning |
|---|---|
| Code | The Python code snippet to execute. This should be a valid Python script. |
| Requirements | A list of PyPI package names that your Python code depends on. These packages will be installed before running the code. |
| Dependencies | A list of system-level dependencies (Alpine packages) required by your Python code. These will be installed via apk package manager. |
Output
The node outputs the result of the executed Python code as JSON in the json field of the output item. Typically, the Python script should print or return JSON-serializable data, which the node captures and makes available downstream.
If the Python code produces binary data, it would typically be handled separately, but based on the provided information, the primary output is JSON-formatted data representing the script's output.
Dependencies
- Requires an API key credential to authenticate with the backend service at
https://prod.0codekit.com. - The backend service executes the Python code; thus, no local Python environment is needed.
- Users must specify any Python package dependencies explicitly to ensure they are installed correctly.
- System dependencies can be specified and will be installed using Alpine Linux's package manager (
apk).
Troubleshooting
- Missing dependencies: If your Python code fails due to missing packages, ensure you have listed all required PyPI packages under "Requirements" and system packages under "Dependencies".
- Syntax errors in Python code: The node expects valid Python syntax. Errors in the code will cause execution failure. Validate your code before running.
- Output parsing errors: The node expects the Python script to output valid JSON. If the output is malformed or not JSON, downstream nodes may fail.
- API authentication issues: Ensure the API key credential is configured correctly; otherwise, the request to the backend service will fail.
- Long-running scripts: Scripts that take too long to execute may time out depending on backend limits.