Pibrella help needed please

Hi The Pi has been sitting in a box for two years but after going to an excellent event at the weekend where we bought a Pibrella, I decided to dust it off. After taking ages to update/upgrade etc, I followed all the instructions that I could find to get the Pibrella working.

I am stuck!

Got to python and typed import Pibrella but nothing is happening and if I try any other commands, they do not work presumably because Pibrella is not imported.

I desperately want to keep my kids interested in this stuff but to be honest I am sick of computing taking so blooming long to get up and going each time I brave it.

Please can someone help?

Taking a blooming long time is an unfortunate hallmark of computing- I think many of us were chipping away at problems until 6am just to learn something trivial like “don’t do that again.” I’m not exactly selling it, but it’s worth it!

Were you at the York Raspberry Jam, by any chance?

Anyway! Without further ado could you supply us with a screenshot ( or a photo ) of whatever output you’re getting from Python? That’d be super helpful, and with any luck it’ll be a trivial little problem that we’ll get sorted in no time.

Thanks!

Thank you. We were all at the Raspberry Jam event and loved it! :) That is why the Raspi has been dusted off.

Ah…apparently it is telling me that new users cannot upload photos. :/

D’oh! Can you email it to me? Phil@pimoroni.com

It was a really great jam and venue, was great to see so many people there and lots of interest in Pibrella!

Will have to look into forum image uploads and see if we can permit them in some cases- they’ll be blocked for spam reasons I imagine, sorry!

Edit: I’ve found out how to change you to a “Basic User”, I don’t know what that’s means but it might let you post images!

Great, thanks. I have sent them to your email.

Brilliant. I’ll keep my eye open. The following is a shot in the dark, but…

When you fire up Python do you use IDLE, and do you use IDLE or IDLE3? I think our Pibrella install instructions only deal with Python 2 ( IDLE ) and lots of people now use Python 3 ( IDLE3 ). The install process is, frustratingly, different for each.

You can install for 3 by going into LXTerminal and typing:

sudo apt-get install python3-pip
sudo pip-3.2 install pibrella

(Edited to pip-3.2! D’oh)

I think the internet ate the pictures- I haven’t seen them come through yet, and I’ve even braved my spam inbox!

It’s probably my new phone! I guess on the upside, as it’s so hopeless, I don’t use it so much! :D

I’ve had another go and when going through the instructions that we got the other day, I have noticed that it says to install Scratch GPIO onto my SD card. I just have the Scratch that came on the card when I got to from Maplin. Could this be the issue?

Missing Scratch GPIO wont affect Python, but it’ll certainly stop you from talking to the Pibrella in scratch.

Generally the steps for getting up and running with Python should be:

  1. Start LXTerminal / Command-line
  2. Type:

Python 2.x

sudo apt-get install python-pip
sudo pip install pibrella
sudo python
>> import pibrella
>> pibrella.light.on()

Python 3.x

sudo apt-get install python3-pip
sudo pip-3.2 install pibrella
sudo python
>> import pibrella
>> pibrella.light.on()

If you’re using IDLE instead of interactive Python on the command-line, the last two lines will be the same.

There are a number of errors you can get; an ImportError meaning the Pibrella library isn’t installed, or is not installed correctly, you can try uninstalling and following the steps again by doing:

sudo pip-3.2 uninstall pibrella
sudo pip uninstall pibrella

Or you might successfully import Pibrella but nothing happens on the board when you type commands- this could be a misplaced board that’s not in the right place on the header ( we managed to do this about 10 times in a Workshop by hurrying through them, with amusing results ).

I think I should get writing an install script for Pibrella and ( possibly ) Scratch GPIO soon!

Tried all of the above. I have managed to install Scratch GPIO too but with no joy.

Whenever I ask it to import pibrella on python (either version) nothing seems to happen.

I shall try turning it off and on again. ;D

Result when I try to install pibrella

Edit: There was meant to be a picture with this !

D’oh! Can you copy & paste the result and post it from the Pi, perhaps?

pi@raspberrypi ~ $ sudo pip install pibrella
Requirement already satisfied (use --upgrade to upgrade): pibrella in /usr/local/lib/python2.7/dist-packages
Downloading/unpacking rpi.gpio>=0.5.5 (from pibrella)
Running setup.py egg_info for package rpi.gpio

Installing collected packages: rpi.gpio
Running setup.py install for rpi.gpio
building ‘RPi.GPIO’ extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -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
compilation terminated.
error: command ‘gcc’ failed with exit status 1
Complete output from command /usr/bin/python -c “import setuptools;file=’/home/pi/build/rpi.gpio/setup.py’;exec(compile(open(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --single-version-externally-managed --record /tmp/pip-YV5K6a-record/install-record.txt:
running install

running build

running build_py

running build_ext

building ‘RPi.GPIO’ extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -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

compilation terminated.

error: command ‘gcc’ failed with exit status 1


Command /usr/bin/python -c “import setuptools;file=’/home/pi/build/rpi.gpio/setup.py’;exec(compile(open(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --single-version-externally-managed --record /tmp/pip-YV5K6a-record/install-record.txt failed with error code 1 in /home/pi/build/rpi.gpio
Storing complete log in /root/.pip/pip.log

Yup! It really took me 40 minutes to do that! :D

Copy and paste that was! Not even typing it out!

Haha fortunately it really helps! Your problem is this:

“Python.h: No such file or directory
compilation terminated.”

I always forget this one! You need to:

sudo apt-get install python-dev

And then reinstall Pibrella with:

sudo pip install pibrella -I

The capital “i” on the end tells pip to ignore already installed stuff and go for a full resinstall.

For Python 3 it’s;

sudo apt-get install python3-dev
pip-3.2 install pibrella -I

Good luck!

1 Like

Whoo hoo! It works! :D

Should it now work with Scratch if I use Scratch GPIO? Also will the PiGlow need anything extra to work for when I dare move onto it?

Thanks for your help.

Hurrah!

I’m honestly not sure about Scratch GPIO, I’ve never actually used or installed it myself! I’ll find out!

As for PiGlow, that should be a little easier because I know all the pitfalls. Following on from my UnicornHat and Dot3k installers, I’m writing scripts to, hopefully, make both Pibrella and PiGlow easy as pie to install.

If you feel like being a crash-test-dummy for an afternoon, you can try:

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

This will also give you the option to install Scratch GPIO 5, which I’ve tested! You should see Scratch GPIO 5 and Scratch GPIO 5 Plus on the desktop, I believe you can use Pibrella from either of these.

There’s a guide to Pibrella in Scratch here, too: http://camjam.me/camjam/wp-content/uploads/2014/02/Pibrella.pdf

Fabulous. I have done that and it is working in Scratch too. :) Thank you.