Install of Blinkt software fails ... python.h not found

I am running…

 curl -sS get.pimoroni.com/blinkt | bash

on one of my Pi 3s to install the Blinkt module and sample code, but it keeps failing at this point…

Installing collected packages: blinkt, RPi.GPIO
Running setup.py install for blinkt

Running setup.py install for RPi.GPIO
building ‘RPi._GPIO’ extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -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
source/py_gpio.c:23:20: fatal error: Python.h: No such file or directory
#include “Python.h”
^
compilation terminated.
error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1
Complete output from command /usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip-build-ajcxm8/RPi.GPIO/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-Tv1PxQ-record/install-record.txt --single-version-externally-

I installed the Blinkt module and samples successfully a few weeks ago on my Pi Zero, so I know it has been working ok.

Any pointers? I have already done

sudo apt-get update
sudo apt-get upgrade

but they do not fix it.

I have the latest version of Jessie with full GUI, i.e., not Jessie Lite, on both of the Pis.

Thanks,
Norm

I have tried the same command on another Pi3 and it fails in exactly the same place with the same error message.

A fix for this went live a few minutes ago, give it another try when you get a chance!

Yep. Thanks. I ‘discovered’ the fix before I read your reply LOL.

I love my little Blinkts!!! I now have 4, one for each Pi. The Pis are calculating Gaussian primes and are now out to 100 billion units from the origin of the complex plane. I use the Blinkts to display every 1,000th prime they find by scrolling the numbers as individual LEDs - one for each digit - using a different colour for each (1=red, 2=green, 3=1+2=red+green, etc).

It has to be every thousandth prime because even the Pi zero calculates them so fast, that they overlap when scrolling, if I have it more frequently. As it is, they’re about every 40 seconds.

I put the code up on GitHub in case anyone is interested. The Python routine is called using a system( … ) call from with my C program that is doing the actual prime calculations.

I realise that this is a somewhat older post and you have said that a fix went out for this; but I am seeing the same error today trying to install the Blinkt! libraries.

Any help gratefully received!

The detail from the pip log file shows this:


Found existing installation: RPi.GPIO 0.6.2
Not uninstalling RPi.GPIO at /usr/lib/python2.7/dist-packages, owned by OS
Running setup.py install for RPi.GPIO
Running command /usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip-build-KqESVx/RPi.GPIO/setup.py’;exec(compile(getattr(
tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-T9yzNF-record/install-record.t
xt --single-version-externally-managed --compile
running install
running build
running build_py
creating build
creating build/lib.linux-armv6l-2.7
creating build/lib.linux-armv6l-2.7/RPi
copying RPi/init.py -> build/lib.linux-armv6l-2.7/RPi
creating build/lib.linux-armv6l-2.7/RPi/GPIO
copying RPi/GPIO/init.py -> build/lib.linux-armv6l-2.7/RPi/GPIO
running build_ext
building ‘RPi._GPIO’ extension
creating build/temp.linux-armv6l-2.7
creating build/temp.linux-armv6l-2.7/source
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-p
rotector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/py_gpio.c -o build/temp.linux-armv6l-2.7/source/py
_gpio.o
source/py_gpio.c:23:20: fatal error: Python.h: No such file or directory
#include “Python.h”
^
compilation terminated.
error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1
Complete output from command /usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip-build-KqESVx/RPi.GPIO/setup.py’;exec(com
pile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-T9yzNF-record/ins
tall-record.txt --single-version-externally-managed --compile:
running install

running build

running build_py

creating build

creating build/lib.linux-armv6l-2.7

creating build/lib.linux-armv6l-2.7/RPi

copying RPi/init.py -> build/lib.linux-armv6l-2.7/RPi

creating build/lib.linux-armv6l-2.7/RPi/GPIO

copying RPi/GPIO/init.py -> build/lib.linux-armv6l-2.7/RPi/GPIO

running build_ext

building ‘RPi._GPIO’ extension

creating build/temp.linux-armv6l-2.7

creating build/temp.linux-armv6l-2.7/source

arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -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-armv6l-2.7/source/py_gpio.o

source/py_gpio.c:23:20: fatal error: Python.h: No such file or directory

#include “Python.h”

                ^

compilation terminated.

error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1


Can’t roll back RPi.GPIO; was not uninstalled

sudo apt-get install python-dev

before running the Blinkt! install script will probably fix it.

actually, an easier solution is to run:

sudo apt-get install python-rpi.gpio python3-rpi.gpio

this will roll the new version of RPi.GPIO released last night from the apt-repo and avoid pip unhelpfully trying to compile it from source.

We are working on a solution for the install script not to fall over in this peculiar scenario (of RPi.GPIO being updated, however infrequently), but in the meantime this should do it, without installing python headers to satisfy the compilation.

That didn’t seem to work for me…

I tried the install of python-rpi-gpio and python3-rpi.gpio and was told that there were both already at the latest version. Then rerunning the Blinkt! install script gives me the same error…

Just trying a full apt-get update and upgrade then will post back…

strange, it worked for me here. We are in the process of hosting our libs in the Raspbian repo, so hopefully all this pip non-sense is not something you’ll have to put up with for much longer.

in the meantime, if a fully updated Raspbian still gives you trouble, then try @JulianNicholls’s solution. It is heavy handed in the sense that compiling from source is unnecessary, but it should shut up pip once and for all!

err, you’re not on Wheezy by any chance right? if so then it’s unlikely the latest rpi.gpio packages have been pushed to that repo.

Sorry, should have said… latest Jessie image here…

Copied from the terminal…

pi@raspberrypi:~ $ sudo apt-get install python-rpi.gpio python3-rpi.gpio
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-rpi.gpio is already the newest version.
python3-rpi.gpio is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@raspberrypi:~ $ curl -sS get.pimoroni.com/blinkt | bash

Which then gives me this…

Installing Blinkt! library for Python 2...

Requirement already up-to-date: blinkt in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: RPi.GPIO in /usr/lib/python2.7/dist-packages (from blinkt)
Cleaning up...

Installing Blinkt! library for Python 3...

Requirement already up-to-date: blinkt in /usr/local/lib/python3.4/dist-packages
Requirement already up-to-date: RPi.GPIO in /usr/lib/python3/dist-packages (from blinkt)
Cleaning up...

Checking for additional software...

python-numpy is already installed
python-psutil is already installed
python-requests is already installed
python-tweepy is required
python3-numpy is already installed
python3-psutil is already installed
python3-requests is already installed

python-numpy is already installed
python-psutil is already installed
python-requests is already installed
python-tweepy is required
Installing python-tweepy...

python3-numpy is already installed
python3-psutil is already installed
python3-requests is already installed

Downloading examples and documentation...

Cloning into 'blinkt'...
remote: Counting objects: 78, done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 78 (delta 5), reused 34 (delta 1), pack-reused 0
Unpacking objects: 100% (78/78), done.
Checking connectivity... done.

Resources for your Blinkt! were copied to
/home/pi/Pimoroni/blinkt

All done!

Enjoy your Blinkt!!

Happy days! Guess the apt-get update sorted it for me!

Time to start playing with my Blinkt!

Thanks for everyone’s help.

Jon

We rushed out a fix for the script, so could be that too. Either way, enjoy your blinkt!

1 Like