Unicorn Hat on Raspbian Jessie

This might help someone:

I formatted a spare SD card and loaded NOOBS.

Installed Raspbian Jessie, and ran the : sudo pip install unicornhat --upgrade command

Failed.

Searched on this error message: Python.h: No such file or directory

Ran this command sudo apt-get install python2.7-dev

Re-ran the : sudo pip install unicornhat --upgrade command

Seems OK, yet to be tested fully.

Full text of error:

pi@raspberrypi ~ $ sudo pip install unicornhat --upgrade
Downloading/unpacking unicornhat
Downloading unicornhat-2.0.4.tar.gz
Running setup.py (path:/tmp/pip-build-KaRTg6/unicornhat/setup.py) egg_info for package unicornhat

Downloading/unpacking rpi-ws281x>=1.1.0 (from unicornhat)
Downloading rpi_ws281x-1.2.1.tar.gz (117kB): 117kB downloaded
Running setup.py (path:/tmp/pip-build-KaRTg6/rpi-ws281x/setup.py) egg_info for package rpi-ws281x

Installing collected packages: unicornhat, rpi-ws281x
Running setup.py install for unicornhat

Running setup.py install for rpi-ws281x
Compiling ws281x library…
building ‘_rpi_ws281x’ 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 -Ilib/ -I/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp.linux-armv6l-2.7/rpi_ws281x_wrap.o
rpi_ws281x_wrap.c:125: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-KaRTg6/rpi-ws281x/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-M5rcJA-record/install-record.txt --single-version-externally-managed --compile:
running install

running build

running build_py

Compiling ws281x library…

creating build

creating build/lib.linux-armv6l-2.7

copying neopixel.py -> build/lib.linux-armv6l-2.7

running build_ext

building ‘_rpi_ws281x’ extension

creating build/temp.linux-armv6l-2.7

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 -Ilib/ -I/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp.linux-armv6l-2.7/rpi_ws281x_wrap.o

rpi_ws281x_wrap.c:125: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


Cleaning up…
Command /usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip-build-KaRTg6/rpi-ws281x/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-M5rcJA-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-KaRTg6/rpi-ws281x
Storing debug log for failure in /root/.pip/pip.log

Yes, I think at this point it’s preferable to use the scripts that take care of dependencies, in this instance:

curl https://get.pimoroni.com/unicornhat | bash

… I have it on good authority it will even get easier in the near future, but mum’s the word ;-)

I have the same problem, unfortunately.

Moreover if I try to use curl https://get.pimoroni.com/unicornhat | bash after it downloads the packages I get this output:

Reading package lists… Done

Installing UnicornHat requirements…

Checking for python-pip…
python-pip already installed.

That’s it, nothing else. Any help?

I just checked the github and I think there was a problem with the script… it’s been fixed but maybe not pushed to the site yet, sorry about that!

what happens if you do:

sudo apt-get install python-pip python-dev
sudo pip install unicornhat

hum, no the script on the site is definitely the right one, so should have worked. Is this on Jessie?
have you updated it recently with:

sudo apt-get update
sudo apt-get upgrade
curl https://get.pimoroni.com/unicornhat | bash

should now work again on Jessie!

And when you’ve seen enough blinky rainbows, how do you stop the Unicorn Hat?

Ending the .py just freezes the coloured lights, how do you get them all to go off.

If possible, I’d rather not shut-down or reboot the Pi.

open an interactive shell then:

>>> import unicornhat
>>> unicornhat.off()