# Nodered python error127 on OpenWRT /bin/sh: python not found

**URL:** <https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950>\
**Category:** General\
**Created:** [13 September 2021 08:56 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950 "2021-09-13T08:56:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 08:56 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/1 "2021-09-13T08:56:29Z")

</div>

I have nodered on OpenWRT and have configured exec node to exexute a python code. python /path/xxx.py. The path is correct. The command works fine on CLI. But from nodered exec node throws an error 127, /bin/sh: python not found. Please advise what is the solution?

---

<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:** [13 September 2021 09:09 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/2 "2021-09-13T09:09:28Z")

</div>

Welcome to the forum @Mansur.

Probably the python command is not in the PATH that is in use when node-red is running. Put the full path to python in the exec node. You can run  
`which python`  
to find that out, which will probably say somethning like `/usr/bin/python`, so in the exec node put `/usr/bin/python /path/xxx.py`

---

<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:** [13 September 2021 09:11 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/3 "2021-09-13T09:11:19Z")

</div>

Is /path/xxx.py an executable file?  
Is the first line of /path/xxx.py a valid "hashbang" eg **#! /usr/bin/python3**?

Then exec /path/xxx.py directly not as a parameter to python.

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 11:28 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/4 "2021-09-13T11:28:01Z")

</div>

Thanks for your reply. Yes the xxx.py is executable (chmod +x) and I have inserted #! /usr/bin/python3 on top of the python file but it still does the same. error 127. My nodered version is 1.2.9.

Do we have any other suggestion? The file is owned by root:root, does it make a difference? All other commands are working on "exec" node such as reboot, touch etc but refusing to execute python.

---

<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:** [13 September 2021 11:36 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/5 "2021-09-13T11:36:19Z")

</div>

What are the exact settings of your exec node?  
What does **ls -l /path/xxx.py** give you?

---

<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:** [13 September 2021 11:38 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/6 "2021-09-13T11:38:40Z")

</div>

The error is saying that python is not found therefore, as @colin said - you need to specify the full path to python.

Have you tried what Colin suggested?

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 17:10 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/7 "2021-09-13T17:10:52Z")

</div>

I somehow missed @Colin reply but I tried it - which python - reveals /usr/python/bin/python which is strange. I put this on the top of the python code as well as on the exec node as /usr/python/bin/python /path/xxx.py (deploy) but results in the same error, also tried after reboot but same error. "/usr/python/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory"

Also tried @jbudd suggestion ls -l /path/xxx.py reveals -rwxr-xr-x 1 root root 1991 Sep 13 18:52 /home/pi/Downloads/telegram/FAhightemp.py

Trying to send high temperature alert Telegram App message to my phone. It works from CLI command but fails on Node-Red exec node command.

Gave a try /usr/python /home/pi/Downloads/telegram/FAhightemp.py, says permission denied.

---

<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:** [13 September 2021 17:45 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/8 "2021-09-13T17:45:37Z")

</div>

[quote="Mansur, post:7, topic:50950"]  
/usr/python/bin/python /path/xxx.py (deploy) but results in the same error  
[/quote

Does that command work in a terminal?

I don't believe that it results in exactly the same error, in node-red. Can you show us the error?

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 17:53 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/9 "2021-09-13T17:53:46Z")

</div>

error127

[quote="Mansur, post:7, topic:50950"]  
"/usr/python/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory"  
[/quote] - (edited/ error added subsequently)

CLI command works perfectly everytime:-  
python /home/pi/Downloads/telegram/FAhightemp.py

---

<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:** [13 September 2021 18:04 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/10 "2021-09-13T18:04:34Z")

</div>

How are you configuring the `exec` command?  
The path to python should be in the `Command` option and the path to the python program. Should be in the `append` option with the ` msg.option` checked off.

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 18:26 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/11 "2021-09-13T18:26:58Z")

</div>

Here is the snapshot

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/2725d87967464b6f2c5e8d7b6cca08862d432a36.png)

This is a LoRaWAN Gateway with OpenWRT on eMMC. I installed pip upgrade and telepot in this manner, not sure if this could cause this?  
root@GATEWAY:~# vtysh  
en  
con t  
python  
pip install --upgrade pip  
pip install telepot

Output:  
pip in /mnt/mmcblk0p1/pysdk/lib/python2.7/site-packages (20.3.4)  
telepot in /mnt/mmcblk0p1/pysdk/lib/python2.7/site-packages (12.7)

---

<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:** [13 September 2021 19:37 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/12 "2021-09-13T19:37:21Z")

</div>

> [@zenofmud](#):
>
> The path to python should be in the `Command` option and the path to the python program. Should be in the `append` option with the ` msg.option` checked off.

I hesitate to say so but it seems fundamentally wrong to run a program by specifying the interpreter on the command line.  
I prefer `Command` /home/pi/Downloads/telegram/FAhightemp.py and `append` blank, or any CLI parameters required by FAhightemp.py, none in this case.  
Still, so far as I know it should work either way.

I wonder if you have installed python libraries just for a single user - "root" but Node-Red exec runs as "pi".  
Only a guess based on you having a /home/pi directory.  
Not sure how to check that. Perhaps from the command line sudo -u pi /home/pi/Downloads/telegram/FAhightemp.py ?

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 20:31 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/13 "2021-09-13T20:31:18Z")

</div>

OpenWRT did not have pi as a directory but it was created by me since I had flow for raspberry pi previously made and wanted to use here. Also OpenWRT does not use sudo. It also does not recognise the -u command (tried without sudo).

I am familiar with raspberry pi but this LoRaWAN Gateway with OpenWRT (not raspberry pi) is the first time use for me. Never used OpenWRT before nor am I familiar with users. In contact with the manufacturer but no help on this python issue so far and that is why decided to post it on Nodered forum.

Generally when I login with root credentials, I get root@GATEWAY:~#, however there are different credentials to login gateway configuration cum nodered on the inherent webpage. You are right I have installed python at the root command promt. In short root credentials are different from nodered platform credentials. Does this indicate that python libraries are installed as root and nodered is working as a user, is that what you mean?

---

<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:** [13 September 2021 20:43 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/14 "2021-09-13T20:43:32Z")

</div>

That's what I'm wondering but it's all speculation because I don't have an openwrt machine to experiment with.

---

<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:** [13 September 2021 20:48 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/15 "2021-09-13T20:48:45Z")

</div>

> [@Mansur](#):
>
> "/usr/python/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory"

So not the same error as previously. It is finding the python program now, but as has suggested it is not finding the libraries for some reason. You have not done as I asked, which was to confirm that the command you are now using still works from the command line.  
`/usr/python/bin/python /path/xxx.py`  
I expect it still to work but that needs to be confirmed.

How are you running node-red?

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 20:51 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/16 "2021-09-13T20:51:44Z")

</div>

Ok. I fully understand.

Exec node takes all other commands such as reboot, touch etc. Is there any other way or any other script that I can use (shell script on exec node, wild guess) to trigger python scripts on the back ground since it works perfectly when executed on the terminal.

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 20:55 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/17 "2021-09-13T20:55:32Z")

</div>

@Colin

Yes on the terminal (CLI) this command also works fine.

root@GATEWAY:~# /usr/python/bin/python /home/pi/Downloads/telegram/FAhightemp.py

Node-red is run with a button on the gateway configuration page or [https://IP:1880](https://IP:1880) with different credentials than root. Is that what you are looking for?

---

<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:** [13 September 2021 21:02 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/18 "2021-09-13T21:02:24Z")

</div>

> [@Mansur](#):
>
> [https://IP:1880](https://IP:1880)

That doesn't run node-red, that just opens a browser viewing it. The question is, how is node-red itself started? I don't know openwrt so I don't know about any button. It would be good to know what user is running node-red, but I suspect that it is root as probably there isn't any other user.

In a terminal what does `echo $LD_LIBRARY_PATH` show?  
If that shows something, then if you run that command in an exec node what does it show?

---

<div class="post-metadata">

**Author:** ![Mansur](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mansur/32/47998_2.png) [@Mansur](https://discourse.nodered.org/u/Mansur)\
**Post date:** [13 September 2021 21:08 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/19 "2021-09-13T21:08:10Z")

</div>

With command on terminal: echo $LD\_LIBRARY\_PATH

Output1:-  
/usr/python/lib:/usr/lib:/usr/lib/iptables

With command on exec node: echo $LD\_LIBRARY\_PATH

Output2:-  
code 0

---

<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:** [13 September 2021 22:00 UTC](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950/20 "2021-09-13T22:00:48Z")

</div>

@jbudd The program running is Python and it runs the users python script.

You can use an `insert` or `change` node and put the command and the options you are using in msg.payload and leave the `Command` option in the `exec` node blank

[Next page](https://discourse.nodered.org/t/nodered-python-error127-on-openwrt-bin-sh-python-not-found/50950.md?page=2)
