-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not resolving module names #11
Comments
Yes sounds like an environment problem. The python script is spawned in a
child process environment that might not have some variables (e.g
PYTHONPATH) that lead it to the library to be imported.
Basically what the node does is just spawn a python process with the script
as the argument (i.e similar to doing $ python script.py)
In the meantime can you use the exec node?
Otherwise try to wrap your env into a virtual env, which is a common
practice in python. The node support virtual env as well.
Cheers
…On Wed, Feb 13, 2019 at 12:45 PM kxkayser ***@***.***> wrote:
Hi. I am trying to use the Pythonshell node to start a program on a RPi.
My default environment is Python 3.5.3. The program file has a shebang
statement reflecting this environment (#!/usr/bin/env python3) and works
fine from the command line, a desktop icon and the NR exec node. When
executing it from the Pythonshell command, it can't find the first import
module. It is finding the program. I assume it's launching the program in
an environment other than where I have the modules installed but this may
not really be the problem. I am quite new to this environment.
Using the "exec" node in NR works fine. I am using exactly the same string
as the payload:
/home/pi/pp/dashboard/./temp_hum_pres_2.py
The error that I get is:
exit code: 1, Traceback (most recent call last):
File "temp_hum_pres.py", line 4, in
import board
ImportError: No module named board
"board" is a module installed in my Python environment from Adafruit.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#11>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA9PoEOO-w90Tq8yDqqhlUU0hVKHk8kEks5vNHmBgaJpZM4a6PVL>
.
|
Yes, I have used the exec node and it is working perfectly. If the node spawns a child process that doesn’t have the PYTHONPATH variable, it’s probably not very useful in my opinion. Just thought I should post the issue.
Thanks.
Ken Kayser
Tobaccoville, NC
[email protected]
From: Nam Giang [mailto:[email protected]]
Sent: Wednesday, February 13, 2019 3:58 PM
To: namgk/node-red-contrib-pythonshell
Cc: kxkayser; Author
Subject: Re: [namgk/node-red-contrib-pythonshell] Not resolving module names (#11)
Yes sounds like an environment problem. The python script is spawned in a
child process environment that might not have some variables (e.g
PYTHONPATH) that lead it to the library to be imported.
Basically what the node does is just spawn a python process with the script
as the argument (i.e similar to doing $ python script.py)
In the meantime can you use the exec node?
Otherwise try to wrap your env into a virtual env, which is a common
practice in python. The node support virtual env as well.
Cheers
On Wed, Feb 13, 2019 at 12:45 PM kxkayser ***@***.***> wrote:
Hi. I am trying to use the Pythonshell node to start a program on a RPi.
My default environment is Python 3.5.3. The program file has a shebang
statement reflecting this environment (#!/usr/bin/env python3) and works
fine from the command line, a desktop icon and the NR exec node. When
executing it from the Pythonshell command, it can't find the first import
module. It is finding the program. I assume it's launching the program in
an environment other than where I have the modules installed but this may
not really be the problem. I am quite new to this environment.
Using the "exec" node in NR works fine. I am using exactly the same string
as the payload:
/home/pi/pp/dashboard/./temp_hum_pres_2.py
The error that I get is:
exit code: 1, Traceback (most recent call last):
File "temp_hum_pres.py", line 4, in
import board
ImportError: No module named board
"board" is a module installed in my Python environment from Adafruit.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#11>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA9PoEOO-w90Tq8yDqqhlUU0hVKHk8kEks5vNHmBgaJpZM4a6PVL>
.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#11 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AsRp13ZGz4yg86GB3kxh0T85-60C1RQKks5vNHxmgaJpZM4a6PVL> . <https://github.com/notifications/beacon/AsRp1_Pz0MYYC80icAqJuSWVbERXjVSaks5vNHxmgaJpZM4a6PVL.gif>
|
Thanks for bringing it up. I’ll look more into it.
…On Wednesday, 13 February 2019, kxkayser ***@***.***> wrote:
Yes, I have used the exec node and it is working perfectly. If the node
spawns a child process that doesn’t have the PYTHONPATH variable, it’s
probably not very useful in my opinion. Just thought I should post the
issue.
Thanks.
Ken Kayser
Tobaccoville, NC
***@***.***
From: Nam Giang ***@***.***
Sent: Wednesday, February 13, 2019 3:58 PM
To: namgk/node-red-contrib-pythonshell
Cc: kxkayser; Author
Subject: Re: [namgk/node-red-contrib-pythonshell] Not resolving module
names (#11)
Yes sounds like an environment problem. The python script is spawned in a
child process environment that might not have some variables (e.g
PYTHONPATH) that lead it to the library to be imported.
Basically what the node does is just spawn a python process with the script
as the argument (i.e similar to doing $ python script.py)
In the meantime can you use the exec node?
Otherwise try to wrap your env into a virtual env, which is a common
practice in python. The node support virtual env as well.
Cheers
On Wed, Feb 13, 2019 at 12:45 PM kxkayser ***@***.***>
wrote:
> Hi. I am trying to use the Pythonshell node to start a program on a RPi.
> My default environment is Python 3.5.3. The program file has a shebang
> statement reflecting this environment (#!/usr/bin/env python3) and works
> fine from the command line, a desktop icon and the NR exec node. When
> executing it from the Pythonshell command, it can't find the first import
> module. It is finding the program. I assume it's launching the program in
> an environment other than where I have the modules installed but this may
> not really be the problem. I am quite new to this environment.
>
> Using the "exec" node in NR works fine. I am using exactly the same
string
> as the payload:
> /home/pi/pp/dashboard/./temp_hum_pres_2.py
>
> The error that I get is:
> exit code: 1, Traceback (most recent call last):
> File "temp_hum_pres.py", line 4, in
> import board
> ImportError: No module named board
>
> "board" is a module installed in my Python environment from Adafruit.
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#11>, or
mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AA9PoEOO-
w90Tq8yDqqhlUU0hVKHk8kEks5vNHmBgaJpZM4a6PVL>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <https://github.com/namgk/
node-red-contrib-pythonshell/issues/11#issuecomment-463367504> , or mute
the thread <https://github.com/notifications/unsubscribe-
auth/AsRp13ZGz4yg86GB3kxh0T85-60C1RQKks5vNHxmgaJpZM4a6PVL> . <
https://github.com/notifications/beacon/AsRp1_
Pz0MYYC80icAqJuSWVbERXjVSaks5vNHxmgaJpZM4a6PVL.gif>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA9PoM8TuLN-FWdScphwhI7YP5bbcsgyks5vNIjmgaJpZM4a6PVL>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I am trying to use the Pythonshell node to start a program on a RPi. My default environment is Python 3.5.3. The program file has a shebang statement reflecting this environment (#!/usr/bin/env python3) and works fine from the command line, a desktop icon and the NR exec node. When executing it from the Pythonshell command, it can't find the first import module. It is finding the program. I assume it's launching the program in an environment other than where I have the modules installed but this may not really be the problem. I am quite new to this environment.
Using the "exec" node in NR works fine. I am using exactly the same string as the payload:
/home/pi/pp/dashboard/./temp_hum_pres_2.py
The error that I get is:
exit code: 1, Traceback (most recent call last):
File "temp_hum_pres.py", line 4, in
import board
ImportError: No module named board
"board" is a module installed in my Python environment from Adafruit.
The text was updated successfully, but these errors were encountered: