n8n 原生 Python 节点适配

原名:n8n-code-python

整理 n8n 原生 Python 输入、返回结构和受限运行环境的错误。

中文 Skills 技能说明

旧 Python 节点迁移后出现变量不存在或导入失败时,应先确认 n8n 的运行模式。提供版本、节点配置、脱敏输入和错误,技能按原生 Python 的 _items、_item 与字典访问方式整理代码草稿,说明与旧 Pyodide 以及 JavaScript 帮助函数的区别。任务运行器需另配,默认导入限制不能自行绕过;确需开放模块由管理员审核。验证返回 json 结构、空数据和错误分支,不能把文档样例当已运行结果,现有业务权限保持不变。

上游能力依据

上游原始适用说明: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", "buildclass 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).

上游 SKILL.md 主要章节(保留原文标题):

使用边界

先核对运行环境、账号、区域、依赖和最小权限。创建资源、改配置、发布服务或产生费用前必须让使用者确认。

作者、翻译与许可证

原作者
Romuald Członkowski 与 n8n-skills contributors
中文翻译
CEOFans翻译
许可证
MIT
上游来源
https://github.com/czlonkowski/n8n-skills/tree/e037563e101749e630e6688d121d04529fe6ee7b/skills/n8n-code-python

适用范围

平台:linux、macos、windows;标签:MCP 与工具、n8n 原生 Python 节点适配、开源技能

安全提示

基础静态扫描不等于绝对安全。技能可能调用命令、浏览器、云服务或本地文件,请在最小权限环境中使用,高风险操作必须人工确认。

如发现侵权、许可证或安全问题,可在本页前台提交投诉,管理员复核后可立即下架。