Nrpgio Python command not running

https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux

Check to see what is the default first. we are guessing it is v3

I’m going to check the python code to see if there’s actually an incompatibility, and if so do a PR to make it able to handle both versions if possible.

image

Apparently my default python is 2.7.16

yeah, and the code is already compatible so it should execute...

Can you execute the following commands from the terminal:
ls -ahl /usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/hardware/
Then, if that doesn't give an error test the following:
python /usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/hardware/nrgpio.py

If that gives the following error

Traceback (most recent call last):
  File "nrgpio.py", line 17, in <module>
    import RPi.GPIO as GPIO
ModuleNotFoundError: No module named 'RPi'

your next step should be to install the RPi python module on the device. To install that in the global python system that executes at /usr/bin/python, type sudo pip install RPi.GPIO.

If it doesn't get that error, I've no clue at all what is going wrong here.

Hi afelix,

Thanks for the detailed instructions. I've run these commands and am getting this response:

Unfortunately not the same error as you had.

Thanks

Edit: Is this because I'm running it without providing the parameters that node-red would?

Not sure if this is relevant, but I have noticed that the error displayed in node red shows "nrpgio" and the python script is "nrgpio.py".

image

I assume that this is just a spelling mistake in the error message, but I thought I should point it out.

No, the output you got is exactly what it should give you following the node-red code. This command is used internally by the node to do whatever it should do.

so yes, this is expected behaviour...

unrelated. Not a spelling mistake either. rpi-gpio out simply means that the rpi-gpio output node was running while sending htat message, nrgpio python command not running is referencing the error message that is given, where nrgpio is the name of the script you ran in the previous post.

hi afelix,

The output is reading nrpgio - as in pgio rather than gpio. I think I picked a bad screenshot as an example.

image

No you did not pick a bad screenshot as example :slight_smile: It's a typo bug in the node itself: https://github.com/node-red/node-red-nodes/blob/8d5ec9b3f6a456fe8bf189dbada9a0a30eb20384/hardware/PiGpio/locales/en-US/36-rpi-gpio.json#L71
That line defines the error message to be displayed in the log output.
Here's the code that throws the error: https://github.com/node-red/node-red-nodes/blob/8d5ec9b3f6a456fe8bf189dbada9a0a30eb20384/hardware/PiGpio/36-rpi-gpio.js#L145
If you look carefully you see it first does node.error, which outputs that message to the error log/debug window. Next it calls node.status, which is setting the message to the status (node), which corresponds to a message without a typo. Again, super minor issue as it is text-only in an error message, but still is one.


I can't believe I haven't asked this yet, but can you post your flow that causes this error? I wonder if the GPIO node is configured correctly. Please follow the instructions here on how to post your code: https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506

Ahh right okay - as long as it was just a typo.

Here is my flow:

[{"id":"2968f5ec.06947a","type":"inject","z":"a332f9fb.e84ee8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"2","crontab":"","once":true,"onceDelay":0.1,"x":230,"y":160,"wires":[["41c9cc96.ab98f4"]]},{"id":"41c9cc96.ab98f4","type":"trigger","z":"a332f9fb.e84ee8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"1","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":400,"y":160,"wires":[["21310221.7b3afe"]]},{"id":"21310221.7b3afe","type":"rpi-gpio out","z":"a332f9fb.e84ee8","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":600,"y":160,"wires":[]}]

As you can see it is just a super simple flow to try and test that my GitHub to Balena was pushing correctly.

(good spot - I will fix the spelling in the error message)

After having a trawl through some other threads I found this command suggested by @dceejay on this post Rpi-gpio input node "stopped"

sudo apt-get install rpi.gpio

This appears to have solved the issue and the pin is now working as it should. Thank you to everyone for your help. Would have been lost on my own!

Personally, I would be a lot more satisfied in knowing why this caused it to work again. Because

that command should have given an error if there were problems with the rpi.gpio package. This is going to keep my mind occupied at night randomly every few months I bet :stuck_out_tongue: But that's a "me" kind of problem. I'm glad this solved it for you.

Yeah it's a weird one - not sure why it stopped working in the first place. Thanks again for your help!

Sorry! Realize this post is older. But this didn't fix it for me. I am running on a Raspberry compute module (CM3). I've followed all instructions here, but my pins are still in stopped status. I hope you can still support.

Here is my flow:

[{"id":"c802d97a.995758","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"8da05ed4.9f81f","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"11","set":true,"level":"0","freq":"","out":"out","x":440,"y":80,"wires":[]},{"id":"81c1cd7c.62e9d","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"12","set":true,"level":"0","freq":"","out":"out","x":440,"y":132,"wires":[]},{"id":"e93b7190.f6715","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"13","set":true,"level":"0","freq":"","out":"out","x":440,"y":182,"wires":[]},{"id":"7a2b0e26.28e2","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"15","set":true,"level":"0","freq":"","out":"out","x":440,"y":234,"wires":[]},{"id":"1fcb30e2.36d20f","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":80,"wires":[["8da05ed4.9f81f"]]},{"id":"4b728ee9.6ee97","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":120,"wires":[["81c1cd7c.62e9d"]]},{"id":"4fa3548e.82336c","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":160,"wires":[["e93b7190.f6715"]]},{"id":"4ce80f4.859d6f","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":200,"wires":[["7a2b0e26.28e2"]]},{"id":"ccbcb301.5f66f","type":"ui_group","name":"Dashboard","tab":"8715a7c2.f768b8","order":1,"disp":true,"width":"6","collapse":false},{"id":"8715a7c2.f768b8","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Try to change the board numbering to BCM

In /home/pi/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py file change line 34 to GPIO.setmode(GPIO.BCM)

1 Like

Hi All - I have changed the basic GPIO nodes t now use BCM rather than Pins - I haven't yet pushed it to the library as I think it needs testing first... you can install in manually by changing to your user directory eg

cd ~/.node-red
npm i node-red-node-pi-gpio@beta

You can now either use the usual pin selector picture - but the pin field beneath is now the BCM GPIO number - and you can enter than manually if desired and it should now work ok with cm3 modules etc...

But as I said - I don't have one to test so please try it and give me feedback...

Many thanks

2 Likes

Old thread, but figured to try anyway...

With the shortage of Raspberry PI units I figured to try a BananaPI (which feels like a mistake this far)...

I've gotten everything running except for the GPIO where I meet this exact error, nrgpio python command not running.

Python version is 2.7 and all the packages/modules referenced/linked seems to be installed.

BananaPI is supposed to be fully compatible over GPIO with all the RPi accessories...

Just figured if anyone has a clue... :slight_smile:

The NR GPIO code uses a python library called RPi.GPIO to do the heavy lifting

When trying to use non-Pi hardware you normally need to hack your installation and replace references to RPi.GPIO with the replacement python GPIO library that comes with the OS for your device

On a standard pi install the file that need modifying is
/home/pi/.node-red\node_modules\node-red-node-pi-gpio\nrgpio.py

1 Like

I am stuck with the same problem right now. Did you find a solution for that?
I tried to install a modified library http://wiki.lemaker.org/BananaPro/Pi:GPIO_library and afterwards adjusted nrgpio.py, but still no success.