domains / families / software-engineering / n8n-code-python

n8n-code-python

combined

Write Python in n8n Code nodes (native Python, `language` pythonNative, n8n 2.x). Use when the user explicitly wants Python in a Code node, when migrating old Pyodide/"Python (Beta)" code that used _input/_json/_node/_now, or when a Python Code node fails with NameError, "Security violations detected", "Import of standard library module … is disallowed", "__build_class__ not found", "A 'json' property isn't a dictionary", or "Python runner unavailable". Covers the only two variables (_items/_item), dict-only access, imports blocked by default, the sandbox's denied builtins, accepted return shapes, and how errors interact with onError. JavaScript is the default for Code nodes — native Python has no n8n helpers and, by default, no imports. EXCEPTION — for Python in the AI-agent-callable Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode), use the n8n-code-tool skill instead (input is _query, return must be a string). Write Python code in n8n Code nodes. Use when writing Python in n8n, using _input/_json/_node syntax, working with standard library, or need to understand Python limitations in n8n Code nodes.

When to use

When not to use

Skill page

Conflict

The two copies describe different n8n Python runtimes and contradict each other on core facts. The first copy (czlonkowski) targets n8n 2.x native Python (pythonNative), where legacy helpers like _input/_json are gone, only _items/_item exist, and imports are blocked by default. The second copy (sickn33) targets the older Pyodide 'Python (Beta)' node, where _input/_json/_node are valid and standard library imports like json/datetime/re are available. Because they disagree on the available variables, the import policy, and the node version, crowning one would hide a real alternative for users on the other version.