# Does the python3 node have issues in picking installed libraries?

**URL:** <https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298>\
**Category:** General\
**Tags:** function-node\
**Created:** [24 March 2022 13:56 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298 "2022-03-24T13:56:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [24 March 2022 13:56 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298/1 "2022-03-24T13:56:44Z")

</div>

Hey !  
I am not sure how the right person to ask would be but here goes.  
I am working on a project which may be nice to share with folks investing on Robinhood.

To start with, i am well versed in python and am thrilled with the capability of the python3 node.

But i need to know if anyone has faced any issues where the python library works fine on the raspberry pi via the python code but has import issues when the same script is run on the same pi with the python3 node?

I can't, for the life of me understand why it doesn't work. Is the python3 node only looking at the standard python libraries and not looking at the user installed libraries?

Would be great if somehow who has resolved this can help me out here ...  
TIA

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 March 2022 15:16 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298/2 "2022-03-24T15:16:54Z")

</div>

Unless someone doesnt come back with a better answer, you should find the node in question on the [flows library](https://flows.nodered.org/search?term=python), see if it has a github link, look in the "issues" page - your question may already be answered. If not, then try raising a question issue on the github repo.

(also let us know how it goes here - for benefit of future readers)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 March 2022 15:19 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298/3 "2022-03-24T15:19:18Z")

</div>

It will be the environment that node red is running under, which is not the same as for a logged in user. Possibly related to the PATH setting or possibly a python specific environment variable.

---

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [25 March 2022 05:22 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298/4 "2022-03-25T05:22:20Z")

</div>

I see someone recommending the pythonshell node in node red which has the same issue.  
Not sure how this can be resolved.  
I will be trying alternative methods.  
When i come across a way to run the python script with node red as a process (maybe) i shall share the flow so that it can be an example for all other users.

---

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [25 March 2022 05:23 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298/5 "2022-03-25T05:23:41Z")

</div>

Yeah, it's surely to do with the Path to the installed libraries of python and not just the default libraries python comes with. Right now, it works for standard libraries like  
import datetime  
import math, etc.

But if it is a library which is installed by the user, it doesn't seem to pick it up

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [25 March 2022 10:30 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298/6 "2022-03-25T10:30:20Z")

</div>

You may try the advice given to you by @Steve-Mcl (check issues on github)  
....  
I got a response to the similar type of question (5,5 years ago) but I have since then decided another strategy for myself, I keep python scripts outside of node-red. I let node-red start & terminate them, control that they are running, restarting if necessary and communicate with them using MQTT, works very well

> <https://github.com/arnauorriols/node-red-contrib-python-function/issues/3>
>
> This is a cool node, been looking for something like this,
> 
> Running Node-RED on …a RPi. Do you know "how to" or where to put additional .py files to import into the node. Like mosquitto.py
> 
> Currently the following fails
> 
> import mosquitto.py
> with error
> Traceback (most recent call last): File "\<string\>", line 101, in \<module\> File "\<string\>", line 59, in python\_function ImportError: No module named mosquitto.py
> 
> as well as
> 
> import /home/pi/mosquitto.py
> with error
> File "\<string\>", line 60 import /home/pi/mosquitto.py ^ SyntaxError: invalid syntax

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 May 2022 10:30 UTC](https://discourse.nodered.org/t/does-the-python3-node-have-issues-in-picking-installed-libraries/60298/7 "2022-05-24T10:30:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
