I am unsure on the steps to set up the task runner for Python on my current N8N envirnonment. I can’t find any documents or information on how to go about this for an npm install. I have only seen steps for docker. Could someone help provide the steps to get this set up?
What is the error message (if any)?
Python runner unavailable: Virtual environment is missing from this system
Share the output returned by the last node
Python runner unavailable: Virtual environment is missing from this system
Internal mode is intended only for debugging. For production, deploy in external mode: Task runners | n8n Docs
Information on your n8n setup
n8n version: 2.4.4
Running n8n via (Docker, npm, n8n cloud, desktop app): npm
I would recommend to consider the docker setup which has even more benefits since the release of v2 and how task runners are implemented now.
If you want to stick to npm, this should be helping you:
Set environment variables to enable the built-in task runner system for Python:
N8N_RUNNERS_ENABLED=true
N8N_RUNNERS_MODE=internal
Install python + tools the usual way for Ubuntu: sudo apt install python3 python3-pip python3-venv python3-dev
Make sure python3 or python is in your system PATH.
If you need specific libraries, list them in N8N_RUNNERS_PY_PACKAGES. n8n will attempt to pip install them into its managed virtual environment upon startup.
Just out of curiosity, what is the reason you’re not working with a docker deployment in a production environment? I’ve managed so many services in my time as Sysadmin, which all have been migrated to docker/kubernetes when possible.
Thank you for your replies, after considering the benefits of docker I have now span up n8n with docker compose. I am now looking at setting up the task runners with Python for this new docker compose install
Since you’re now on docker-compose, the recommended setup in n8n 2.x is to run external task runners using the n8nio/runners image and connect them to the Primary n8n instance acting as the task broker. Enable runners on the Primary (N8N_RUNNERS_ENABLED=true,
N8N_RUNNERS_MODE=external), expose port 5679, and configure a shared N8N_RUNNERS_AUTH_TOKEN (must match on all services).
Then start a Python runner container pointing to http://n8n:5679 with N8N_RUNNERS_LAUNCHER=python
Thank you for your reply, I have now got the task runner connected successfully!
I was trying to import json and bs4 in my python but have now hit the error “Line 1: Import of standard library module ‘json’ is disallowed. Allowed stdlib modules: none Line 2: Import of external package ‘bs4’ is disallowed. Allowed external packages: none”
I have created a dockerfile and task-runners.json file to get around this but the issue is persisting and not sure where it’s going wrong.
FROM n8nio/runners
USER root
RUN cd /opt/runners/task-runner-python && uv pip install beautifulsoup4
COPY n8n-task-runners.json /etc/n8n-taskrunners.json
USER runner
thanks for sharing the config, this helps pinpoint the issue.
Your configuration is almost correct, but the runner is not loading your custom task-runners.json file.
Because of that, the Python runner starts with the default sandbox, where no stdlib or external packages are allowed, which is why you see:
Import of standard library module ‘json’ is disallowed
Import of external package ‘bs4’ is disallowed
What’s wrong
In your Dockerfile, you are copying the config to:
/etc/n8n-taskrunners.json
But the runner only reads the config from this exact path:
/etc/n8n-task-runners.json
(missing hyphen)
Because of this filename mismatch, your N8N_RUNNERS_STDLIB_ALLOW and N8N_RUNNERS_EXTERNAL_ALLOW settings are never applied.