Skip to content
MoveWorkflows

Pipedream Python steps → n8n Python Code node

Updated 2026-10-21 · 3 min read

n8n runs Python in the same Code node that runs JavaScript, so a Pipedream Python step has a direct home. Two things change: the handler shape (handler(pd) becomes code that reads _items and returns items) and package imports, which are blocked on n8n Cloud and allow-listed on self-hosted n8n. This page covers both and lists what doesn't translate.

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 exposes only _items (all-items mode) and _item (each-item mode) and uses bracket access, not dot access (Code node docs, 2.0 breaking changes). Older examples using _input.all() were written for the removed Pyodide version.

Mapping table

Pipedream Python n8n Python Code node
def handler(pd): 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 data through the previous node or add a JavaScript Code node that collects it
return {...} return [{"json": {...}}]
pd.flow.exit() return []
pd.respond({...}) Respond to Webhook node
os.environ["KEY"] A credential on the node that needs it
pd.inputs["data_store"] Data Table node (no static data in Python)
import requests HTTP Request node
Auto-installed packages Cloud: none. Self-hosted: installed in the runner image and allow-listed

Because native Python sees only its input items, steps that read several earlier steps need restructuring. A JavaScript Code node can still use $('Node name').

Imports

Pipedream installed packages on import automatically, with a magic comment for name mismatches (import mappings) and version pins such as # pipedream add-package pandas==2.0.0 (Python docs).

In n8n:

  • n8n Cloud: "the Python option for the Code node doesn't allow users to import any Python libraries" (Code node docs). Not even json or datetime.
  • Self-hosted: Python needs task runners in external mode. Install packages in an image built on n8nio/runners (uv pip install pandas in /opt/runners/task-runner-python) and allow-list them in n8n-task-runners.json under N8N_RUNNERS_EXTERNAL_ALLOW (third-party) and N8N_RUNNERS_STDLIB_ALLOW (standard library). See the task runner docs. By default, imports made inside a package are checked against the allow-list too (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): eval, exec, open, getattr, setattr, type, dir, globals, __build_class__ and others. Blocking __build_class__ means class definitions fail, so 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). n8n's workflow static data is JavaScript only, and Data tables can't be read from a Code node. Put a Data Table node before the Python node (to read) or after it (to write). Our converter flags these steps red for this reason. More: Pipedream data stores to n8n.

Should you rewrite in JavaScript?

On n8n Cloud, a Python step that needs any import has to be rewritten anyway, either in plain Python without imports or 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

Not affiliated with Pipedream or n8n.

FAQ

Can n8n run Python code?
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 with N8N_RUNNERS_EXTERNAL_ALLOW (third-party) and N8N_RUNNERS_STDLIB_ALLOW (standard library) in the task runner config.
Does n8n Python support workflow static data?
No. $getWorkflowStaticData works only in the JavaScript Code node. Use a Data table node instead.

Related

Sources