Struggling with External Runners image

Describe the problem/error/question

Dear n8n Community,

I’m writing to you today as a very enthusiastic n8n user. I’ve been incredibly impressed with n8n’s capabilities and ease of use for automating workflows, and I continue to be a big fan of the platform!

I was particularly excited about the introduction of the new “external” runners method for Python, as it promised to open up a lot of possibilities for more complex data processing and custom logic directly within n8n. The idea of offloading Python execution to dedicated runners is a fantastic architectural improvement.

However, I must admit, I’m feeling a bit disheartened and frankly, quite a bit frustrated with the setup process for these external Python runners. After multiple hours of trying, debugging, and following various paths, I still haven’t managed to get my Python nodes to recognize external libraries like requests, numpy, pandas.

Here’s a summary of what I’ve tried so far in my Portainer stack (n8n-postgres), using n8nio/n8n:1.118.1 for both the main n8n instance and the custom runner image:

  1. Custom Dockerfile (task-runners-image/Dockerfile):

    • Initially, I tried to build a custom runner image based on docker.n8n.io/n8nio/n8n:1.118.1.

    • I attempted to RUN pip install requests numpy pandas oipd directly within the Dockerfile.

    • I also tried to create and COPY extras.txt (containing the package list) and n8n-task-runners.json (to allow external modules) into /etc/ in the runner image.

    • Result: The Docker build for the runner image now completes successfully, meaning the files are copied and pip install commands (when present in the Dockerfile) execute without error. My pip freeze output from inside the running runner container (docker exec -it n8n-runners bash followed by pip freeze) clearly shows requests, numpy, pandas as installed in /usr/local/lib/python3.13/site-packages.

  2. Manual pip install within the Running Runner Container:

    • After the Docker build, I manually exec’d into the running n8n-runners container (docker exec -it n8n-runners bash).

    • From within the container, I executed pip install requests numpy pandas.

    • My pip freeze output from inside the container confirmed these packages were successfully installed in /usr/local/lib/python3.13/site-packages.

    • Result: Despite confirming the packages are installed in the container’s system-wide Python environment, my Python nodes in n8n still report “No module named ‘requests’”. This strongly suggests that the Python environment used by the n8n Python node is completely isolated and does not pick up these system-wide installations.

I’m at a loss for what to try next. It feels like the Python runner is either ignoring these configurations, or there’s a subtle interaction I’m missing between the main n8n instance and the external runner regarding Python environment setup.

My intended solution (and what I hoped for) was indeed to enable package installation via environment variables or a clear, documented process in the Dockerfile for external runners. It would be incredibly helpful to have a straightforward way to ensure these essential packages are available.

Could anyone in the community shed some light on this or provide a working example for configuring external Python runners with additional packages? Any guidance would be immensely appreciated.

Thank you for your time and for this amazing platform!

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

[quote=“Shaked_Melman, post:6, topic:201521”]

This worked for me for self hosted -

I’ve got these 4 files in my directory:

**docker-compose.yml**

```

services:

n8n:

image: n8nio/n8n:1.111.0

container_name: n8n-main

environment:

  - N8N_RUNNERS_ENABLED=true

  - N8N_RUNNERS_MODE=external

  - N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0

  - N8N_RUNNERS_AUTH_TOKEN=your-secret-here

  - N8N_NATIVE_PYTHON_RUNNER=true

ports:

  - "5678:5678"

volumes:

  - n8n_data:/home/node/.n8n

task-runners:

image: n8n-runner:custom

container_name: n8n-runners

environment:

  - N8N_RUNNERS_TASK_BROKER_URI=http://n8n-main:5679

  - N8N_RUNNERS_AUTH_TOKEN=your-secret-here

\# critical for overriding allowed deps

volumes:

  - ./n8n-task-runners.json:/etc/n8n-task-runners.json

depends_on:

  - n8n

volumes:

n8n_data:

```

**n8n-task-runners.json**

copy from:

and edit the list of allowed libs in the bottom

“N8N_RUNNERS_STDLIB_ALLOW”: “”,

“N8N_RUNNERS_EXTERNAL_ALLOW”: “”

**extras.txt:**

```

# like a requirements.txt

# pypdf==4.2.0

```

**Task Runner dockerfile:**

```

FROM n8nio/runners:1.111.0

COPY extras.txt /app/task-runner-python/extras.txt

RUN set -e; \

PY_BIN="/opt/runners/task-runner-python/.venv/bin/python"; \\

if \[ ! -x "$

PY_BIN

" ]; then PY_BIN=“$(command -v python3)”; fi; \

"$PY_BIN" -m ensurepip --upgrade; \\

"$PY_BIN" -m pip install --no-cache-dir -r /app/task-runner-python/extras.txt

```

**When in directory containing all files:**

```

1. docker build -t n8n-runner:custom

2. docker compose up

```

That should basically be it. Now you can use those extra libs in a native python code node

[/quote]

Here in this topic post I think it may help with this issue.