n8n - 💡(How to fix) Fix ## Bug: Python Task Runner fails on native npm install — `src/` folder missing from published package

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

ModuleNotFoundError: No module named 'src'

Root Cause

Failed to start Python task runner in internal mode. because its virtual environment is missing from this system.

Fix Action

Workaround

# 1. Create the directory n8n actually looks in
sudo mkdir -p /usr/lib/node_modules/@n8n/task-runner-python

# 2. Copy the source from inside n8n's own node_modules
sudo cp -r /usr/lib/node_modules/n8n/node_modules/@n8n/task-runner-python/. \
    /usr/lib/node_modules/@n8n/task-runner-python/

# 3. Clone the repo to get the missing src/ folder
git clone --depth 1 https://github.com/n8n-io/n8n.git /tmp/n8n-src
sudo cp -r /tmp/n8n-src/packages/@n8n/task-runner-python/src \
    /usr/lib/node_modules/@n8n/task-runner-python/

# 4. Create venv and install dependencies
sudo rm -rf /usr/lib/node_modules/@n8n/task-runner-python/.venv
sudo python3 -m venv /usr/lib/node_modules/@n8n/task-runner-python/.venv
sudo /usr/lib/node_modules/@n8n/task-runner-python/.venv/bin/pip install websockets

After this, the Python Task Runner registers successfully.

Code Example

Failed to start Python task runner in internal mode. because its virtual environment is missing from this system.

---

const pythonDir = path.join(__dirname, '../../../@n8n/task-runner-python');
// resolves to: /usr/lib/node_modules/@n8n/task-runner-python/.venv/bin/python

---

ModuleNotFoundError: No module named 'src'

---

# 1. Create the directory n8n actually looks in
sudo mkdir -p /usr/lib/node_modules/@n8n/task-runner-python

# 2. Copy the source from inside n8n's own node_modules
sudo cp -r /usr/lib/node_modules/n8n/node_modules/@n8n/task-runner-python/. \
    /usr/lib/node_modules/@n8n/task-runner-python/

# 3. Clone the repo to get the missing src/ folder
git clone --depth 1 https://github.com/n8n-io/n8n.git /tmp/n8n-src
sudo cp -r /tmp/n8n-src/packages/@n8n/task-runner-python/src \
    /usr/lib/node_modules/@n8n/task-runner-python/

# 4. Create venv and install dependencies
sudo rm -rf /usr/lib/node_modules/@n8n/task-runner-python/.venv
sudo python3 -m venv /usr/lib/node_modules/@n8n/task-runner-python/.venv
sudo /usr/lib/node_modules/@n8n/task-runner-python/.venv/bin/pip install websockets
RAW_BUFFERClick to expand / collapse

Bug Description

Bug: Python Task Runner fails on native npm install — src/ folder missing from published package

Environment

  • n8n version: 2.21.7
  • Install method: Global npm (sudo npm install -g n8n)
  • OS: Ubuntu 24 (Linux, native install — not Docker)
  • Node.js version: (add yours)
  • Python version: 3.12.3

To Reproduce

What happened

After installing n8n globally via npm and starting it, the Python task runner fails with:

Failed to start Python task runner in internal mode. because its virtual environment is missing from this system.

Creating the venv at ~/.n8n/runner-venvs/python (as suggested in the docs) does not fix the issue.

Root cause (after investigation)

After digging into the source, I found two problems:

1. Wrong venv path /usr/lib/node_modules/n8n/dist/task-runners/task-runner-process-py.js resolves the venv path as:

const pythonDir = path.join(__dirname, '../../../@n8n/task-runner-python');
// resolves to: /usr/lib/node_modules/@n8n/task-runner-python/.venv/bin/python

This is outside the n8n package folder entirely, so the venv created at ~/.n8n/runner-venvs/python is never found.

2. src/ Python source files are not included in the npm release The @n8n/task-runner-python package published to npm does not include the src/ folder (the actual Python runner code). It only contains a .venv with pip. So even after creating the venv at the correct path, n8n fails with:

ModuleNotFoundError: No module named 'src'

Expected behavior

Workaround

# 1. Create the directory n8n actually looks in
sudo mkdir -p /usr/lib/node_modules/@n8n/task-runner-python

# 2. Copy the source from inside n8n's own node_modules
sudo cp -r /usr/lib/node_modules/n8n/node_modules/@n8n/task-runner-python/. \
    /usr/lib/node_modules/@n8n/task-runner-python/

# 3. Clone the repo to get the missing src/ folder
git clone --depth 1 https://github.com/n8n-io/n8n.git /tmp/n8n-src
sudo cp -r /tmp/n8n-src/packages/@n8n/task-runner-python/src \
    /usr/lib/node_modules/@n8n/task-runner-python/

# 4. Create venv and install dependencies
sudo rm -rf /usr/lib/node_modules/@n8n/task-runner-python/.venv
sudo python3 -m venv /usr/lib/node_modules/@n8n/task-runner-python/.venv
sudo /usr/lib/node_modules/@n8n/task-runner-python/.venv/bin/pip install websockets

After this, the Python Task Runner registers successfully.

Debug Info

Suggested fix

One or more of the following:

  • Include the src/ folder in the files field of packages/@n8n/task-runner-python/pyproject.toml so it is published with the package
  • Update the error message to give actionable guidance for native installs (not just Docker)
  • Document the native Linux setup steps in https://docs.n8n.io/hosting/configuration/task-runners/

Additional notes

The @n8n/task-runner-python package also requires Python >=3.13 in pyproject.toml, but works fine on Python 3.12 when dependencies are installed manually. This may also be worth revisiting.

Happy to submit a PR for any of the above if maintainers can point me to the right approach.

Operating System

Ubuntu 24 (Linux, native install — not Docker)

n8n Version

  • n8n version: 2.21.7

Node.js Version

Node.js version: 24

Database

SQLite (default)

Execution mode

main (default)

Hosting

self hosted

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING