Hey,
I would like to know how you guys install modules to a server to run Python code.
Tried to install module globally, but no luck .
My script looks like:
GPT says, that Python path might be wrong:
In my case its:
/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js
Hi, did you actually install this python module? (can you use it outside of n8n, in a simple script) I can only speak for the javascript side, but additional libraries you want to use, need to be installed before they can be referenced.
Regards
J.
Well, itâs easy to run Python in the terminal. It simply works, even with the same modules. Everything is okay, but when I start running Python from n8n, it cannot be found, and I try to find a reason.
Well, i actually tried this, and it does not work from the terminal⌠It cannot find the library
apk update&&apk add py3-pypdf
the only import that works from the command-line is from pypdf import PdfReader
if you run execute command node âpython3 <testscript.py>â it works as well.
But the thing is that I donât want to store the Python file on the server - I want it to be stored and launched from n8n. I donât have issues running Python files from the terminal, but I would like to know if I can run it directly from n8n. I assume that n8n simply doesnât get the correct path to Python.
While this note is specifically about Node.js modules, I originally ran into a similar âmodule not foundâ error while trying to install a Python library. Just wanted to share this in case youâre facing a similar error but working with Node â this is how such issues with missing Node modules can often be resolved.
- First, update the n8n environment file to allow external Node.js modules by adding this line:
NODE_FUNCTION_ALLOW_EXTERNAL=axios,jsonwebtoken,form-data
- Only Node.js modules listed here can be used inside
Function
and FunctionItem
nodes in n8n.
- Make sure these modules are installed globally using npm:
npm install -g axios jsonwebtoken form-data
These global modules become available for use inside your n8n instance (if allowed in the ENV variable).
- Note: Only Node.js modules are supported in n8n Function nodes. Python libraries (like PyMuPDF) will not work in this context.
This setup works for most n8n installations, but may vary slightly depending on your environment (Docker, native, etc.).
1 Like