n8n-code-python
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).
Pinned to revision 19cd793f4789, so it is the text this page describes rather than whatever the author pushed since.
Files
- skills/n8n-code-python/SKILL.md
- skills/n8n-code-python/COMMON_PATTERNS.md
- skills/n8n-code-python/README.md
Every link opens the file at its source, pinned to the revision this page describes.