0

I'm trying to run a python script saved on my local system in node-red which is running as a docker container. I copied the python script into the docker container as the exec node was unable to locate the file using this command - cat /local/file/path | docker exec -i <running-container-id> sh -c 'cat > /inside/docker/file/path'

But now I'm getting the following error - Traceback (most recent call last): File "outlier.py", line 2, in from pandas import read_csv ModuleNotFoundError: No module named 'pandas'

I had installed pandas on my local but it's not being found by the exec node. Any help is appreciated, thanks.

2
  • Can you show your dockerfile? Commented Sep 27, 2021 at 14:38
  • Have you installed all the Python pre-reqs (e.g. pandas) for your script into the container? The Node-RED container only containers the Python modules it requires (e.g. got node-gyp) Commented Sep 27, 2021 at 16:39

1 Answer 1

2

When applications run inside a Docker container they only have access to the libraries/modules included inside the container. They have no access to anything in the host machine.

So if you want to run Python scripts that have dependencies on Python modules you will need to create a custom Docker container that extends the official Node-RED container and then installs those modules.

Node-RED provides doc about extending it's container here

Sign up to request clarification or add additional context in comments.

4 Comments

I'm using docker desktop so how do I install these libraries on my node-red container? There's no dockerfile and the preferences tab in docker desktop is also not helping.
Another issue is I'm trying to take an influxdb column as the input array for my python script. So would connecting influxdb-in node to to exec node and giving arr = msg.columnRequired in the python file work?
As described in the doc I linked to, you have to create your own Dockerfile and then user this to build a new container. Your second comment is a totally separate question that has nothing to do with what you asked here.
Thanks. Ok sorry, I'll post that question separately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.