Pipedream Python steps → n8n Python Code node
Updated 2026-10-21 · 4 min read
- n8n runs Python in the same Code node as JavaScript, natively since n8n 2.0.
- On n8n Cloud the Python Code node can't import any library, not even json.
- Self-hosted: install packages in an n8nio/runners image and allow-list them.
n8n runs Python in the same Code node that runs JavaScript. So a Pipedream Python step has a direct home. Two things change. First, the handler shape: handler(pd) becomes code that reads _items and returns items. Second, package imports: n8n Cloud blocks them, and self-hosted n8n allows them through an allow-list. This page covers both and lists what doesn't translate.
What to do now
- Find your Python steps. The free report lists every Python step in your export. Check my export
- Decide where they run. On n8n Cloud, Python can't import anything. Steps that need libraries need self-hosted n8n or a rewrite.
- Rewrite the handler. Replace
handler(pd)with code that loops over_itemsand returns a list of items. - Move data store calls out of the code. Put a Data Table node before or after the Python node.
Before and after
Pipedream (Python docs, Python 3.12):
def handler(pd: "pipedream"):
body = pd.steps["trigger"]["event"]["body"]
if not body.get("email"):
return pd.flow.exit("no email")
return {"email": body["email"].lower()}
n8n Code node, language Python, mode "Run Once for All Items":
out = []
for item in _items:
body = item["json"]["body"]
if body.get("email"):
out.append({"json": {"email": body["email"].lower()}})
return out
In n8n 2.x, native Python gives you only two variables. _items holds all items in all-items mode. _item holds the current item in each-item mode. You read fields with brackets, not with dots (Code node docs, 2.0 breaking changes). Older examples use _input.all(). They were written for the removed Pyodide version.
Mapping table
| Pipedream Python | n8n Python Code node |
|---|---|
def handler(pd): |
The Code node body |
pd.steps["trigger"]["event"] |
_items[0]["json"] when the trigger is the previous node |
pd.steps["other_step"]["key"] |
Not directly. Pass the data through the previous node, or add a JavaScript Code node that collects it |
return {...} |
return [{"json": {...}}] |
pd.flow.exit() |
return [] |
pd.respond({...}) |
A Respond to Webhook node |
os.environ["KEY"] |
A credential on the node that needs it |
pd.inputs["data_store"] |
A Data Table node (Python has no static data) |
import requests |
An HTTP Request node |
| Auto-installed packages | Cloud: none. Self-hosted: installed in the runner image and allow-listed |
Native Python sees only its input items. So steps that read several earlier steps need restructuring. A JavaScript Code node can still use $('Node name').
Imports
Pipedream installed packages automatically when you imported them. A magic comment handled name mismatches (import mappings). You could pin versions, for example # pipedream add-package pandas==2.0.0 (Python docs).
In n8n it depends on where you run it:
- n8n Cloud: "the Python option for the Code node doesn't allow users to import any Python libraries" (Code node docs). Not even
jsonordatetime. - Self-hosted: Python needs task runners in external mode. A task runner is the separate process n8n uses to run Code node code. Install packages in an image built on
n8nio/runners, for exampleuv pip install pandasin/opt/runners/task-runner-python. Then allow-list them inn8n-task-runners.json. UseN8N_RUNNERS_EXTERNAL_ALLOWfor third-party packages andN8N_RUNNERS_STDLIB_ALLOWfor the standard library. See the task runner docs.
One trap on self-hosted n8n: by default, imports made inside a package are checked against the allow-list too. That is because N8N_RUNNERS_ALLOW_TRANSITIVE_IMPORTS is false. So list the package's own dependencies as well, or turn transitive imports on.
The runner also blocks some built-ins by default (N8N_RUNNERS_BUILTINS_DENY). Among them are eval, exec, open, getattr, setattr, type, dir, globals, __build_class__ and others. Because __build_class__ is blocked, class definitions fail. Ported code that defines classes needs a rewrite.
Data stores in Python steps
Pipedream Python steps could use data stores through pd.inputs["data_store"] (docs). In n8n, workflow static data is JavaScript only. A Code node also can't read Data tables. So put a Data Table node before the Python node to read, or after it to write. For this reason our converter flags these steps red. More: Pipedream data stores to n8n.
Should you rewrite in JavaScript?
On n8n Cloud you have to rewrite a Python step that needs any import. You can rewrite it in plain Python without imports. Or you can rewrite it in JavaScript, with HTTP Request nodes doing the API calls. On self-hosted n8n, keep Python if the step depends on libraries like pandas. The runner setup is a one-time job.
Next steps
- Check a Python step for free: Code node compatibility check
- See all Python steps in your export: free report
- JavaScript steps: code steps to the n8n Code node
- Full guide: migrate Pipedream to n8n
Not affiliated with Pipedream or n8n.
FAQ
Can n8n run my Pipedream Python steps?
Yes. The n8n Code node runs Python. Since n8n 2.0 it runs natively through task runners. The older Pyodide-based version was removed.
Can I import Python libraries on n8n Cloud?
No. On n8n Cloud the Python Code node can't import any library, including the standard library.
How do I use pandas or requests in self-hosted n8n?
Extend the n8nio/runners image to install the packages. Then allow-list them in the task runner config: N8N_RUNNERS_EXTERNAL_ALLOW for third-party packages and N8N_RUNNERS_STDLIB_ALLOW for the standard library.
Does n8n Python support workflow static data?
No. $getWorkflowStaticData works only in the JavaScript Code node. Use a Data table node instead.
Sources (7)
- https://pipedream.com/docs/workflows/building-workflows/code/python
- https://pipedream.com/docs/workflows/building-workflows/code/python/import-mappings
- https://pipedream.com/docs/workflows/building-workflows/code/python/using-data-stores
- https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code
- https://docs.n8n.io/changelog/v20-breaking-changes
- https://docs.n8n.io/deploy/host-n8n/configure-n8n/set-up-task-runners
- https://docs.n8n.io/build/code-in-n8n/cookbook/built-in-methods-and-variables-examples/getworkflowstaticdata