0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions132

Code → Execute Python Code

AI-generated

Overview

The node "0CodeKit" provides a versatile toolbox of no-code utilities grouped by various resource types, including code execution capabilities. Specifically, the Execute Python Code operation under the Code resource allows users to run custom Python scripts within their workflows. This is useful for scenarios where you want to perform complex data processing, integrate with Python libraries, or execute logic that is not natively supported by other nodes.

Practical examples include:

  • Running data transformation scripts using popular Python libraries.
  • Executing machine learning inference or data analysis snippets.
  • Automating tasks that require Python-specific packages.
  • Quickly prototyping and testing Python code as part of an automation pipeline.

Properties

Name Meaning
Code The Python code snippet to execute. Users write their Python script here. For example, importing libraries, defining functions, and printing JSON results.
Requirements A list of PyPI (Python Package Index) library dependencies your Python code requires. These are installed before running the code. Explicitly specifying these is recommended for accuracy.
Dependencies System-level dependencies required by your Python code, installed via Alpine's package manager (apk). Useful for native libraries or system tools your Python packages depend on.

Output

The node outputs the result of the executed Python code in the json field. Typically, this will be the JSON-parsed output printed by the Python script. If the Python code prints JSON-formatted data, it will be parsed and returned as structured JSON in the workflow.

If the Python code produces binary data, the node can handle it accordingly, but the primary focus is on JSON output from the executed script.

Dependencies

  • Requires an API key credential to authenticate requests to the external service at https://prod.0codekit.com.
  • The node sends the Python code and dependency information to this external API endpoint /code/python via POST request.
  • The environment must support installing specified PyPI packages and Alpine system packages as declared in the properties.

Troubleshooting

  • Common issues:

    • Missing or incorrect Python dependencies may cause runtime errors. Always specify all required PyPI packages explicitly.
    • System dependencies not declared might lead to failures if native libraries are missing.
    • Syntax errors or exceptions in the Python code will cause the node to fail.
    • Network or authentication issues with the external API service can prevent code execution.
  • Error messages:

    • Errors related to package installation usually indicate missing or misspelled package names in Requirements or Dependencies.
    • Python runtime errors will reflect the exception message from the executed script.
    • Authentication errors suggest invalid or missing API credentials.
  • Resolution tips:

    • Double-check and explicitly list all Python and system dependencies.
    • Validate Python code syntax before running.
    • Ensure API credentials are correctly configured in n8n.
    • Review error details returned by the node for specific Python exceptions.

Links and References

Discussion