# "nrgpio python command not running" error

**URL:** <https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388>\
**Category:** General\
**Created:** [2 December 2023 20:15 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388 "2023-12-02T20:15:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [2 December 2023 20:15 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/1 "2023-12-02T20:15:11Z")

</div>

Hi! After not being able to solve this issue with a lot of Google, I decided to ask for help here. But first things first, the system:

Rpi 2B  
Latest Raspberry OS Lite (installed today)  
did a full `apt-get update && apt-get upgrade` right after  
Installed node.red with the installer script recommended here: [Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi)  
Python version: 3.9.2  
Node-RED version: v3.1.1  
Node.js version: v18.19.0  
Linux 6.1.64-v7+ arm LE

Now my issue - all nodes/workflows (mainly reading tons of 1wire temp sensors and plotting data) work fine. However, I can not control GPIOs from within node.red:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/7/07c81972e8bcf97f9a78e80603c283ff76e3badb.png)

I tried manually installing the gpio package as recommended elsewhere (`sudo apt-get install rpi.gpio`), no change. I can directly control the GPIO (and confirmed the pin changing status with a LED) the following way: `sudo python .node-red/node_modules/node-red-node-pi-gpio/nrgpio.py out 12 {1|0}`.

I am a bit lost how to further debug this issue... If anyone has some ideas, I would be very grateful.

---

<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:** [2 December 2023 21:43 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/2 "2023-12-02T21:43:26Z")

</div>

I don't know if it will help but could you stop and restart node-red using  
`node-red-stop`  
`node-red-start`  
and then post the full output here. Copy/paste please not screenshot.

Also please post the file .node-red/package.json.

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [3 December 2023 14:00 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/3 "2023-12-03T14:00:19Z")

</div>

Here you go:

```auto
pi@nodered:~ $ node-red-stop
Stop Node-RED

Use node-red-start to start Node-RED again

pi@nodered:~ $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.178.36:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
3 Dec 14:57:45 - [info]
Welcome to Node-RED
===================
3 Dec 14:57:45 - [info] Node-RED version: v3.1.1
3 Dec 14:57:45 - [info] Node.js version: v18.19.0
3 Dec 14:57:45 - [info] Linux 6.1.64-v7+ arm LE
3 Dec 14:57:50 - [info] Loading palette nodes
3 Dec 14:57:57 - [info] Dashboard version 3.6.1 started at /ui
3 Dec 14:57:59 - [info] Settings file : /home/pi/.node-red/settings.js
3 Dec 14:57:59 - [info] Context store : 'default' [module=memory]
3 Dec 14:57:59 - [info] User directory : /home/pi/.node-red
3 Dec 14:57:59 - [warn] Projects disabled : editorTheme.projects.enabled=false
3 Dec 14:57:59 - [info] Flows file : /home/pi/.node-red/flows.json
3 Dec 14:57:59 - [info] Server now running at http://127.0.0.1:1880/
3 Dec 14:57:59 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
3 Dec 14:58:00 - [info] Starting flows
3 Dec 14:58:00 - [info] Started flows
3 Dec 14:58:02 - [error] [rpi-gpio out:3bb6a3d2f961c981] nrgpio python command not running
3 Dec 14:59:09 - [error] [rpi-gpio out:3bb6a3d2f961c981] nrgpio python command not running
3 Dec 15:00:09 - [error] [rpi-gpio out:3bb6a3d2f961c981] nrgpio python command not running

```

package.json:

```json
{
  "name": "node-red-project",
  "description": "initially created for you by Node-RED 3.1.1",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "node-red-contrib-1wire": "~0.0.2",
    "node-red-contrib-bigtimer": "~2.8.5",
    "node-red-contrib-bool-gate": "~1.0.2",
    "node-red-contrib-buffer-parser": "^3.2.2",
    "node-red-contrib-play-audio": "^2.5.0",
    "node-red-dashboard": "~3.6.1",
    "node-red-node-pi-gpio": "^2.0.6",
    "node-red-node-ping": "^0.3.3",
    "node-red-node-random": "^0.4.1",
    "node-red-node-serialport": "^2.0.0",
    "node-red-node-smooth": "^0.1.2"
  }
}

```

---

<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:** [3 December 2023 14:56 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/4 "2023-12-03T14:56:02Z")

</div>

I can't see anything wrong there. I think we need an expert on gpio.

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [3 December 2023 15:10 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/5 "2023-12-03T15:10:33Z")

</div>

Thanks for your help so far - much appreciated!

My best guess is, it is either a PATH or permission issue (nodered can not access the GPIOs), or a python version incompatibility (maybe the GPIO control plugin was installed to the system python version and nodered uses its own it brings along?), or it has issues with my ancient Pi and I would need a newer Pi or an older application version?

Just guessing in the dark there though, I'm at wits end.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 December 2023 15:18 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/6 "2023-12-03T15:18:58Z")

</div>

If you haven't put much work in on it, I would personally try it again but with the last not the current OS version and see if that's the issue

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [3 December 2023 15:30 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/7 "2023-12-03T15:30:28Z")

</div>

I would mainly have to copy my flow over, not that big of a deal, but the pi is in the boiler room in the basement and not easy to reach (to swap the SD), the less on-hardware-time I have to spend, the better. Would be my last resort.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 December 2023 15:41 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/8 "2023-12-03T15:41:29Z")

</div>

can you cd into your `/home/pi/.node-red/node_modules/node-red-node-pi-gpio` directory and run `./nrgpio ver` on the command line and show us the result. And also run `python --version` and report that as well

Thanks

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [3 December 2023 16:10 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/9 "2023-12-03T16:10:43Z")

</div>

Check! Here is the output.

```bash
pi@nodered:~ $ cd /home/pi/.node-red/node_modules/node-red-node-pi-gpio
pi@nodered:~/.node-red/node_modules/node-red-node-pi-gpio $ ./nrgpio ver
0.7.0
pi@nodered:~/.node-red/node_modules/node-red-node-pi-gpio $ python --version
Python 3.9.2

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 December 2023 22:08 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/10 "2023-12-03T22:08:27Z")

</div>

ok - now confused as that is the command the runtime should be running... and it seems to be installed ok and python is ok as well...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 December 2023 22:36 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/11 "2023-12-03T22:36:14Z")

</div>

can you try running node-red locally - ie `node-red-stop` to stop the service then in your `/home/pi/.node-red` directory just run `node-red`

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [3 December 2023 22:49 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/12 "2023-12-03T22:49:24Z")

</div>

Thank you for the suggestion, sadly this led me to the exact same result:

```auto
pi@nodered:~/.node-red $ node-red
3 Dec 23:48:03 - [info]

Welcome to Node-RED
===================

3 Dec 23:48:03 - [info] Node-RED version: v3.1.1
3 Dec 23:48:03 - [info] Node.js version: v18.19.0
3 Dec 23:48:03 - [info] Linux 6.1.64-v7+ arm LE
3 Dec 23:48:08 - [info] Loading palette nodes
3 Dec 23:48:14 - [info] Dashboard version 3.6.1 started at /ui
3 Dec 23:48:16 - [info] Settings file : /home/pi/.node-red/settings.js
3 Dec 23:48:16 - [info] Context store : 'default' [module=memory]
3 Dec 23:48:16 - [info] User directory : /home/pi/.node-red
3 Dec 23:48:16 - [warn] Projects disabled : editorTheme.projects.enabled=false
3 Dec 23:48:16 - [info] Flows file : /home/pi/.node-red/flows.json
3 Dec 23:48:16 - [info] Server now running at http://127.0.0.1:1880/
3 Dec 23:48:16 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

3 Dec 23:48:17 - [info] Starting flows
3 Dec 23:48:17 - [info] Started flows
3 Dec 23:48:19 - [error] [rpi-gpio out:3bb6a3d2f961c981] nrgpio python command not running

```

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [15 December 2023 20:14 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/13 "2023-12-15T20:14:18Z")

</div>

I take it that these logs were not helpful in narrowing it down? Anything left for me to do that's not a clean install of the system? Might actually switch over to a Pi 3B I recently freed up elsewhere, so I'll probably have to do it anyway. If I can help with any logs until then, pls tell 🙂

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [15 December 2023 22:48 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/14 "2023-12-15T22:48:06Z")

</div>

> [@ebastler](#):
>
> it has issues with my ancient Pi and I would need a newer Pi

There should be no problem running on an older Raspberry Pi.

> [@ebastler](#):
>
> I can directly control the GPIO (and confirmed the pin changing status with a LED) the following way: `sudo python .node-red/node_modules/node-red-node-pi-gpio/nrgpio.py out 12 {1|0}`.

I don't know but I doubt if Node-red calls nrgpio.py with sudo.  
What happens if you run your command line without `sudo` or `python`?  
What does `ls -l ~/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py` show you?

There have been significant changes to GPIO handling with RPiOS Bookworm, you might find everything works with the latest Bullseye version.

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [15 December 2023 23:13 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/15 "2023-12-15T23:13:48Z")

</div>

> [@jbudd](#):
>
> What does `ls -l ~/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py` show you?

```auto
ls -l ~/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py
-rwxr-xr-x 1 pi pi 7185 Dec 2 15:22 /home/pi/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py

```

> [@jbudd](#):
>
> What happens if you run your command line without `sudo` or `python`?

```auto
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py out 12 1
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 3: import: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 4: import: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 5: import: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 6: import: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 7: import: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 8: from: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 10: try:: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 11: raw_input: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 12: except: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 13: raw_input: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 15: bounce: command not found
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 17: syntax error near unexpected token `sys.argv'
./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py: line 17: `if len(sys.argv) > 2:'

```

```auto
python ./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py out 12 1
Traceback (most recent call last):
  File "/home/pi/./.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py", line 70, in <module>
    GPIO.setup(pin,GPIO.OUT)
RuntimeError: No access to /dev/mem. Try running as root!

```

> [@jbudd](#):
>
> There should be no problem running on an older Raspberry Pi.

That's good to know, thanks!

Oh, I'm still on Bullseye - that was what the rpi imager offered me as the latest stable when I set it up.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [15 December 2023 23:36 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/16 "2023-12-15T23:36:34Z")

</div>

OK that shows it does need to run with sudo and python and it was apparently not installed by root.

I have no more ideas, all I can suggest is using the exec node to call it instead of the gpio node.  
Put a debug node on the 2nd output to show any errors

> [@ebastler](#):
>
> Oh, I'm still on Bullseye

Thats RPiOS Legacy then. Perhaps I was too hasty saying an old Pi should be OK (I know Node-red runs on a Pi Zero but I don't use the gpio nodes)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [16 December 2023 14:47 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/17 "2023-12-16T14:47:04Z")

</div>

@ebastler I just

1. flashed an SD card with 2023-05-03-raspios-bullseye-armhf-lite.img then
2. Put it in a Pi 2 Model B v1.1 and then
3. ran `sudo apt update` then
4. ran `sudo apt full-upgrade -y` then
5. ran `bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node18`

Node-red starts fine and adding a inject connected to a `rpi-gpio out` sending 0 or 1 or true or false they all work fine.

```auto
pmw@gpiopi:~ $ node-red
16 Dec 09:43:03 - [info] 

Welcome to Node-RED
===================

16 Dec 09:43:03 - [info] Node-RED version: v3.1.3
16 Dec 09:43:03 - [info] Node.js version: v18.19.0
16 Dec 09:43:03 - [info] Linux 6.1.21-v7+ arm LE
16 Dec 09:43:07 - [info] Loading palette nodes
16 Dec 09:43:13 - [info] Settings file : /home/pmw/.node-red/settings.js
16 Dec 09:43:13 - [info] Context store : 'default' [module=memory]
16 Dec 09:43:13 - [info] User directory : /home/pmw/.node-red
16 Dec 09:43:13 - [warn] Projects disabled : editorTheme.projects.enabled=false
16 Dec 09:43:13 - [info] Flows file : /home/pmw/.node-red/flows.json
16 Dec 09:43:13 - [warn] 

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

16 Dec 09:43:13 - [warn] Encrypted credentials not found
16 Dec 09:43:13 - [info] Server now running at http://127.0.0.1:1880/
16 Dec 09:43:13 - [info] Starting flows
16 Dec 09:43:13 - [info] Started flows

```

This leads me to believe that you have installed or uninstalled something else that is causing the conflict.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [16 December 2023 15:01 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/18 "2023-12-16T15:01:02Z")

</div>

Wow I admire your patience running apt -y full-upgrade on a Pi2 🙂

---

<div class="post-metadata">

**Author:** ![ebastler](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ebastler](https://discourse.nodered.org/u/ebastler)\
**Post date:** [16 December 2023 15:12 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/19 "2023-12-16T15:12:34Z")

</div>

@zenofmud huh, this is very weird, I can not remember having done anything else. Thank you for your patience - this clearly shows the issue is local to my system and likely due to some config error or package conflict.

I did not run the `apt full-upgrade` (what does that do?) but I think `apt update` and `apt upgrade` should be enough. Only thing I did was change some things in config.txt because I'm using a 800x480 touchscreen on the pi, and enable 1wire temp sensors.

I think at this point I will give up debugging, export my workflows and reinstall the whole thing. Faster and less effort than trying to find the conflict.

Since I freed a Pi3B from another application yesterday, I'll probably swap the controller anyway - Pi3 should be a whole lot faster than Pi2. Then the effort of going through a reinstall will hurt less 😄

I will report back next week when I found the time to swap the Rpi over and do a clean install!

Thanks to everybody for the help in debugging and narrowing down my issue.

---

<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:** [16 December 2023 15:12 UTC](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388/20 "2023-12-16T15:12:36Z")

</div>

Hopefully, at 2.5 you did `sudo apt update`

[Next page](https://discourse.nodered.org/t/nrgpio-python-command-not-running-error/83388.md?page=2)
