Back to Blog
n8nPythonAutomation

n8n Code Node Python Limitations: What You Can't Do (And How to Fix It)

Your n8n Python Code node is more limited than you think—here's what doesn't work and 3 ways to fix it

TomDecember 28, 20258 min read

You're building an n8n workflow. You need to process a CSV with pandas. You add a Python Code node, write your script, and... it fails.

ModuleNotFoundError: No module named 'pandas'

You can't pip install. You're stuck.

Sound familiar?

In this guide, we'll cover exactly what the n8n Python Code node can and can't do, why these limitations exist, and—most importantly—three workarounds to get real Python running in your workflows.


What Is the n8n Code Node?

The Code node in n8n allows you to add custom logic to your workflows. n8n actually has two versions:

  1. JavaScript Code node - The original, more mature option
  2. Python Code node - A separate, more restricted feature

Both are useful for data transformations, calculations, and API response parsing. But both come with strict limitations—and Python is significantly more restrictive.

Quick Comparison

FeatureJavaScript Code NodePython Code Node
AvailabilityAll n8n versionsLimited/beta (version-dependent)
Pre-installed packagesSome built-in utilities, no arbitrary npmVery restricted subset, not even all stdlib
Can install packages?NoNo
Timeout limitsShort, configuration-dependentShort, configuration-dependent

n8n Python Code Node: The 4 Big Limitations

1. Extremely Limited Library Access

We tested 86 popular Python packages to see exactly what n8n supports. The results are stark:

EnvironmentPackages AvailableAvailability
n8n Cloud0 (zero external packages)0%
n8n Self-Hosted5 (PIL, bs4, numpy, pandas, pytz)5.8%
Apyrun100+ (all tested packages + more)100%

What n8n Self-Hosted HAS:

  • PIL (Pillow) - Basic image manipulation
  • bs4 (BeautifulSoup) - HTML parsing
  • numpy - Array operations
  • pandas - DataFrames
  • pytz - Timezone handling

What n8n Self-Hosted DOESN'T have:

  • requests - HTTP requests
  • playwright - Headless browsers
  • pdfplumber - PDF extraction
  • openai/anthropic - AI APIs
  • openpyxl - Excel files
  • scikit-learn - Machine learning
  • ...and 76 other commonly used packages

What n8n Cloud has:

  • Literally nothing. Zero external packages allowed.
  • Even standard library imports like json, sys, datetime are blocked
  • Only basic Python syntax (variables, loops, dicts)
# ✅ Works on n8n self-hosted
import pandas as pd
import numpy as np

df = pd.DataFrame({'a': [1, 2, 3]})

# ❌ Fails on n8n self-hosted (and cloud)
import requests  # ModuleNotFoundError
import playwright  # ModuleNotFoundError
import pdfplumber  # ModuleNotFoundError
import openai  # ModuleNotFoundError

# ❌ Fails on n8n CLOUD (even pandas blocked)
import pandas  # Security violations detected
import json  # Security violations detected

2. Massive Discrepancy Between Cloud and Self-Hosted

What packages you can use depends entirely on your n8n deployment type.

n8n Cloud (Verified December 2025):

  • Zero external packages allowed
  • Zero standard library imports allowed (json, sys, os, datetime, etc.)
  • Even __builtins__ access is blocked
  • Only basic Python syntax works (variables, loops, basic math)

Error message when trying to import anything:

Security violations detected
Line 1: Import of external package 'pandas' is disallowed. 
Allowed external packages: none
n8n Cloud blocks even built-in functions like type() - making the Python node nearly useless
Self-hosted test: Only 5 packages available out of 86 tested (5.8% availability)

The reality:

  • Cloud users: Python Code node is essentially useless for real work
  • Self-hosted users: Limited to data manipulation with pandas/numpy only
  • Both: Can't do web scraping, PDF processing, API calls, ML, or browser automation

3. Hard 60-Second Timeout Limit

We tested the actual timeout limits by running busy loops until failure. Results:

EnvironmentTimeout LimitConfigurable?
n8n Cloud60 seconds (hard limit)❌ No
n8n Self-Hosted60 seconds (default)⚠️ Requires instance config change

Common timeout scenarios:

  • Processing large files (even a 5MB CSV can be slow)
  • Making multiple API calls in sequence
  • Complex data transformations with nested loops
  • File downloads or uploads
  • Waiting for slow external services

4. No Direct File System Access

In the standard Python Code node environment, you can't reliably read or write arbitrary files to disk. All data must flow through n8n's JSON and binary data abstractions.

What you can't do:

  • Download a file, process it locally, and save it back
  • Use libraries that expect file paths (like opencv, pdfplumber, reportlab)
  • Create temporary files for intermediate processing
  • Work with the file system in any traditional way

Why Do These Limitations Exist?

Before we jump into solutions, it's worth understanding why n8n restricts the Python Code node so heavily.

  1. Security - Allowing arbitrary code execution and package imports on n8n's servers would be a massive security risk.
  2. Resource Management - If every workflow could use unlimited CPU and memory, one workflow could crash the entire n8n instance.
  3. Stability - Limiting what the Code node can do prevents workflows from interfering with each other.
  4. Simplicity - Keeping the Code node lightweight means it starts fast and runs consistently.

Fair enough—but users still need real Python. So what are your options?


Workaround #1: Self-Hosted with Community Python Node

If you're self-hosting n8n with Docker, you can create a custom Docker image that installs a community Python node (like n8n-nodes-python) or provides Python + packages for use via the Execute Command node.

⚠️ IMPORTANT: Installing Python packages in the Docker image does NOT make them available to the built-in Python Code node. The built-in node is sandboxed and controlled by n8n's task runner.

Pros:

  • Full control over packages (via community node or Execute Command)
  • No external service dependency

Cons:

  • Requires Docker knowledge
  • Maintenance overhead (rebuilding on updates)
  • Memory/CPU usage can crash your instance
  • Doesn't work for n8n cloud users
# Example Dockerfile
FROM n8nio/n8n:latest
RUN apk add --update python3 py3-pip
RUN pip3 install pandas numpy requests
# Then install n8n-nodes-python as per its GitHub README

Workaround #2: Execute Command Node (Self-Hosted Only)

Use n8n's Execute Command node to call a Python script stored on your server, passing data via stdin/stdout or temporary files.

Pros:

  • Can use any Python packages installed on the server
  • No Docker rebuilding needed

Cons:

  • Only works for self-hosted (not n8n cloud)
  • Requires shell access to the server
  • Security risk if not configured properly
  • Still bound by the same n8n timeout limits

Workaround #3: External Python Webhook (Best Solution)

Deploy your Python script to an external service (like Apyrun, your own VPS, AWS Lambda, or serverless platform). n8n calls the script via an HTTP Request node.

Pros:

  • Works with n8n cloud AND self-hosted
  • Any Python package supported by your hosting environment
  • Higher/more flexible timeout limits
  • No Docker management
  • Minimal infrastructure overhead (if using a managed service)

Cons:

  • ⚠️ Adds external dependency (but HTTP is standard)
  • ⚠️ Requires webhook service account (Apyrun has free tier)

Step-by-step:

1. Create Python script in Apyrun

import pandas as pd
from io import BytesIO

def process_excel(file_data):
    df = pd.read_excel(BytesIO(file_data))
    df = df.dropna()
    return df.to_json()

2. Deploy and get URL

https://apyrun.io/u/yourname/excel-processor/webhook

3. Add HTTP Request node in n8n

Method: POST
URL: https://apyrun.io/u/yourname/excel-processor/webhook
Headers:
  Authorization: Bearer YOUR_APYRUN_TOKEN
Body:
  { "data": "{{ $json }}" }

Comparison: Which Workaround Should You Choose?

CriteriaCustom DockerExecute CommandExternal Webhook
Works on n8n cloud?
Library access✅ Full✅ Full✅ Full
Timeout limits⚠️ Same as n8n⚠️ Same as n8n✅ Higher
Maintenance❌ High⚠️ Medium✅ Low
Best forSelf-hosted power usersQuick local scriptsCloud users + production

Quick Decision Tree

Are you on n8n cloud?

  • ✅ YesExternal webhook (only option)
  • ❌ No → Continue...

Do you have Docker/DevOps skills?

  • ✅ Yes → Custom Docker or External webhook
  • ❌ NoExternal webhook

Do you need production-grade reliability?

  • ✅ YesExternal webhook (managed service)
  • ❌ No → Any option works

For most users: External webhook offers the best balance of ease, flexibility, reliability, and minimal infrastructure overhead.


Conclusion: The Built-In Code Node Has Limits—But You Have Options

The n8n Python Code node is useful for simple transformations, but it was never designed to be a full Python environment.

What we covered:

  1. The 4 major limitations: Restricted libraries, cloud/self-hosted discrepancy, short timeouts, no file system access
  2. Why they exist: Security, resource management, stability
  3. 3 workarounds: Custom Docker, Execute Command, External webhook

The takeaway: Don't fight the Code node's limitations. Use the right tool for the job:

  • For simple logic → Use the built-in Code node
  • For real Python → Use an external webhook

Try It Yourself

If you need Python packages in your n8n workflows and don't want to manage Docker or servers:

What you get:

  • 100+ packages pre-installed including pandas, Playwright, pdfplumber, and more
  • Higher execution limits than Code node
  • Works with n8n cloud and self-hosted
  • Deploy scripts in seconds