RPi GPIO Library on Ubuntu Snappy Core

Hello,

I started to play with ubuntu core to make a simple monitoring tools. To comply with my poor level and lack of time for developping it, I would like to run Node-Red on Ubuntu Core (that's working), the problem is I can't install the RPi GPIO library to access to them via Node-Red.
I installed the Classic Snap to run those commands :

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip python-dev
sudo pip install RPi.GPIO

Everything run smoothly except the last one. When I running it, I'm stuck with that :

Collecting RPi.GPIO
Downloading https://files.pythonhosted.org/packa...O-0.6.3.tar.gz
Installing collected packages: RPi.GPIO
Running setup.py install for RPi.GPIO ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-QRZKqJ/RPi.GPIO/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-OqtqFt-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/RPi
copying RPi/init.py -> build/lib.linux-armv7l-2.7/RPi
creating build/lib.linux-armv7l-2.7/RPi/GPIO
copying RPi/GPIO/init.py -> build/lib.linux-armv7l-2.7/RPi/GPIO
running build_ext
building 'RPi._GPIO' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/source
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/py_gpio.c -o build/temp.linux-armv7l-2.7/source/py_gpio.o
unable to execute 'arm-linux-gnueabihf-gcc': No such file or directory
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

Unfortunately, google seems not to be my friend on that, so I'm turning on the community.

Thanks by advance.

Xavier.

Looks like it can't find the GCC compiler, maybe try installing the build-essential package first, (but I'm only guessing now)

Hello dceejay and thanks for your answer !

I just tried and I can install it. But Node-Red doesn't see it (maybe bescause the Node-Red Snap can't access to the Pi OS).

If it can help someone else, the process to install it :
Switch in classic mode :

xav@localhost:~$ snap start classic

Then when you tried to run the pip install you'll have that :
(classic)xav@localhost:~$ sudo pip install RPi.GPIO

Traceback (most recent call last):

File "/usr/bin/pip", line 11, in <module>

sys.exit(main())

File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main

locale.setlocale(locale.LC_ALL, '')

File "/usr/lib/python2.7/locale.py", line 581, in setlocale

return _setlocale(category, locale)

locale.Error: unsupported locale setting

To fix it, you just have to type :

(classic)xav@localhost:~$ export LC_ALL=C

And relaunch the pip install :
(classic)xav@localhost:~$ sudo pip install RPi.GPIO

        The directory '/home/xav/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

        The directory '/home/xav/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

        Collecting RPi.GPIO

        Downloading https://files.pythonhosted.org/packages/e2/58/6e1b775606da6439fa3fd1550e7f714ac62aa75e162eed29dbec684ecb3e/RPi.GPIO-0.6.3.tar.gz

        Installing collected packages: RPi.GPIO

        Running setup.py install for RPi.GPIO ... done

        Successfully installed RPi.GPIO-0.6.3

        You are using pip version 8.1.1, however version 18.0 is available.

        You should consider upgrading via the 'pip install --upgrade pip' command.

By the way, I tried to upgrade the pip install but it break everything so it probably a good choice to not doing it.

Anyway, when I relaunch node-red, I still have the warning [rpi-gpio] Warning : Cannot find Pi RPi.GPIO python library

Any idea ?

Thanks by advance !

Xav.

Hmm - thinking about it - for now at least I would maybe instead try the gpiod node - https://www.npmjs.com/package/node-red-node-pi-gpiod
which will talk to the pigpiod daemon instead... which you can install with sudo apt-get install pigpio
as this node doesn't use any native libraries

Just to check - are you running your Ubuntu Snappy Core on a Pi?

Hello dceejay and thanks again for your help. The command return me a E: Unable to locate package pigpio

After looking the documentation, the gpiod daemon seems to be implement on Raspbian not on ubuntu (but I'm maybe wrong). So even if I find a way to install pi-gpiod, the daemon will not be present and can't work. Is it correct ?

As far as I understand it, the "simplest" way to do it is to repackage a snap of node-red with GPIO Library, like that when the snap is mounted, it will have access to this library directly inside the snap ?

Xav.

Hello cymplecy, yes indeed, I'm on snappy core.

Not answering the question I know, but I wonder why you want to use Ubuntu core rather than Raspbian Lite, which is a cut down version of raspbian with no GUI or other non-essential overheads.

1 Like

Hello Colin. It was a hard choice because Raspbian is very well documented and would be simpler to implemant (already done couple of projects with it), but it is not IoT centered, Ubuntu Core is, like auto-update and the fact that this update concern only the system, not dependencies of the snap (had several problems with libraries updates with it but I'm not enough competent to fix all problems and it take me ages to fix them).

OK, I am not sure I fully understand what you are saying. However you have obviously considered the alternative which is really what I was concerned about.

So... yes... If you do do that please consider raising a pull request back onto the node red snap project - https://github.com/dceejay/nodered.snap so we can all benefit . Though I'm not sure how we make that optional for those not running on a Pi...

Thanks

Well, even if I don't really know how to do that, I'm gonna try to do it and keep you posted. Thanks again for your support dceejay.

Xav.

Not sure if you've found this - may be useful - https://forum.snapcraft.io/t/raspberry-pi-3-sample-python-snap-to-read-data-gpio-pins/3629/2
good luck !

Hi dceejay, no, didn't find it but it could definitely help ! I'm investing on the pi3gpio snap and on wiring.pi also. I keep you posted.

Xav.