techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

RPi.gpio v0.3.1a and Raspbian

Sun Jul 29, 2012 6:24 pm

Now probably being silly here, but gone through what I thought was install instructions (gunzip, tar, pythoin install), however get conisstent error.

Using Raspbian and squeeze, trying to install when building the Python 3 install gives a gcc error of

"Unable to find Python.h"

So which dependency are we missing for Python 3?

NOT interested in python 2.x
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

Larry
Posts: 1
Joined: Sun Jul 29, 2012 7:53 pm
Location: United States

Re: RPi.gpio v0.3.1a and Raspbian

Sun Jul 29, 2012 8:01 pm

had the same problem. what solved it for me...

do this:

Code: Select all

sudo apt-get install python-dev
then try this again (from the RPi.GPIO... directory):

Code: Select all

sudo python setup.py install

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Mon Jul 30, 2012 12:23 am

Sorted eventually and to all those looking for details here is how WE did it.

Configuring RPi.GPIO 0.3.1a, Raspbian and Python 3

Our setup is
Raspbian image 2012-07-15-wheezy-raspbian.img
Python 3.2

Previous we had done ' sudo apt-get update ' on system, you may want
to do this as well.

Steps (well detailed to help newer users and those unfamiliar with these things)

1/ This is important one missed out on most guides and is an assumption

From command prompt or terminal window

Code: Select all

sudo apt-get install python3-dev
(note python 2 users will need to get at least python2-dev)

This can take several minutes to run.

2/ Using a web browser download to Pi from http://pypi.python.org/pypi/RPi.GPIO/

Click on link "RPi.GPIO 0.3.1a" (http://pypi.python.org/pypi/RPi.GPIO/0.3.1a)
or newer version if that exists

When Page appears click on "Downloads" link

Right click on Filename "RPi.GPIO-0.3.1a.tar.gz" Select "Save as" Save in your
home directory.

Close browser

3/ From command prompt or terminal

Ensure you are in directory that the file from step 3 was saved to

Type the following commands
Quick hint to save time typing long file names you can type the first
few letter(s) and pressing TAB key the system will fill in as many
characters of the filename that it can, if it can find it in that directory

Code: Select all

 gunzip RPi.GPIO-0.3.1a.tar.gz 
(quick type method type gu<TAB key> R<TAB KEY><ENTER KEY>)

Code: Select all

 tar -xvf RPi.GPIO-0.3.1a.tar
(quick type method type tar -xvf R<TAB KEY><ENTER KEY>)

Code: Select all

 cd RPi.GPIO-0.3.1a
(quick type method type cd R<TAB KEY><ENTER KEY>)

Code: Select all

sudo python3 setup.py install
This will take a few minutes, wait for it to finish

4/ Using Xwindows graphical interface
Logged on as pi user
Start menu -> Run
type in sudo idle3
press OK
At IDLE prompt (>>>) type

Code: Select all

 import RPi.GPIO as gpio
if you get prompt (>>>) with no errors successfully installed

Logged on as root user (note default root user has NO password)
Use any IDLE3 shortcut or run method above but just type idle3
At IDLE prompt (>>>) type

Code: Select all

import RPi.GPIO as gpio

if you get prompt (>>>) with no errors successfully installed

Note to run any programmes for this module you must run your python
programme as root or by sudo <filename>.py from command prompt.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

dhewison
Posts: 4
Joined: Thu Aug 02, 2012 2:28 pm

Re: RPi.gpio v0.3.1a and Raspbian

Thu Aug 02, 2012 2:35 pm

Hi,

Context: I'm a total novice at Linux

I cannot unzip RPi.GPIO-0.3.1a.tar.gz

gunzip RPi.GPIO-0.3.1a.tar.gz

produces "unexpected end of line", I've tried downloading RPi.GPIO-0.2.0.tar.gz and that produces the same result too, so I've either picked a bad day to do it or I'm doing something stupid (my money is on the latter). Any help in pointing me in the right direction would be gratefully appreciated.

David

hrgdavid
Posts: 15
Joined: Thu Jan 05, 2012 10:39 pm

Re: RPi.gpio v0.3.1a and Raspbian

Thu Aug 02, 2012 2:58 pm

On Raspbian, I used the command:

Code: Select all

tar -zxvf RPi.GPIO-0.3.1a.tar.gz
Not sure if you're the same level of beginner as me (ie real beginner), but I found this useful http://www.youtube.com/watch?v=q_NvDTZIaS4 to get some LED's flashing....

Good luck ;-)

dhewison
Posts: 4
Joined: Thu Aug 02, 2012 2:28 pm

Re: RPi.gpio v0.3.1a and Raspbian

Thu Aug 02, 2012 3:32 pm

Thanks, I finally got it unzipped after a series of .tar0 etc directories, not exactly sure the steps I took so I probably will be very little wiser next time :-)

clapper
Posts: 34
Joined: Mon Jan 30, 2012 2:10 pm

Re: RPi.gpio v0.3.1a and Raspbian

Fri Aug 03, 2012 7:22 pm

I have similar problems here; neither Python 2 nor 3 seem to recognize the GPIO module:
"import RPi.GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named GPIO"

importing only RPi works, but that's it. After several tries, I copy/pasted exactly techpauls instructions, but still the same error.

hrgdavid
Posts: 15
Joined: Thu Jan 05, 2012 10:39 pm

Re: RPi.gpio v0.3.1a and Raspbian

Fri Aug 03, 2012 9:18 pm

I am a complete beginner at this, so apologise if you've tried this, but I think that line should be: "import RPi.GPIO as GPIO".

At least it is in my code (which works), And when I remove "as GPIO", I get a similar error message to the one you're seeing.

Hope this helps.

David L.

User avatar
MattHawkinsUK
Posts: 538
Joined: Tue Jan 10, 2012 8:48 pm
Location: UK
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Fri Aug 03, 2012 9:26 pm

To install on Raspbian I used :

Code: Select all

wget http://raspberry-gpio-python.googlecode.com/files/python-rpi.gpio_0.3.1a-1_armhf.deb
and then :

Code: Select all

sudo dpkg -i python-rpi.gpio_0.3.1a-1_armhf.deb
I have been using GPIO happily using Python v2.
My Raspberry Pi blog and home of the BerryClip Add-on board : http://www.raspberrypi-spy.co.uk/
Follow me on Google+, Facebook, Pinterest and Twitter (@RPiSpy)

clapper
Posts: 34
Joined: Mon Jan 30, 2012 2:10 pm

Re: RPi.gpio v0.3.1a and Raspbian

Sat Aug 04, 2012 8:46 am

Yep, that works, thanks.
By the way: this won't update itself by apt-get upgrade, right?

Jochen
Posts: 14
Joined: Fri Jul 27, 2012 7:20 pm

Re: RPi.gpio v0.3.1a and Raspbian

Sat Aug 04, 2012 7:30 pm

I've installed GPIO and all that, but every time I run a program the error message
IOError: [Errno13] Permissiuon denied: '/sys/class/gpio/export'

I've built this lovely buffered input/output card but I have yet to get a single line working.

Jochen

User avatar
croston
Posts: 705
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Sat Aug 04, 2012 8:11 pm

Jochen wrote:I've installed GPIO and all that, but every time I run a program the error message
IOError: [Errno13] Permissiuon denied: '/sys/class/gpio/export'

I've built this lovely buffered input/output card but I have yet to get a single line working.

Jochen
If you get that error message then you are using an old version (0.2.0). I suggest you download and install version 0.3.1a as described above Also note that the error message is because you are not running as root.

User avatar
Vindicator
Posts: 314
Joined: Sat Sep 17, 2011 11:10 pm
Location: Susanville Ca USA
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Sat Aug 04, 2012 9:13 pm

another words to clarify if it says permission denied you need to put (sudo) in front of the line.
If you are more worried about ,spelling, punctuation or grammar you have probably already missed the point so please just move on.

Jochen
Posts: 14
Joined: Fri Jul 27, 2012 7:20 pm

Re: RPi.gpio v0.3.1a and Raspbian

Sun Aug 05, 2012 2:12 pm

croston wrote:
Jochen wrote:I've installed GPIO and all that, but every time I run a program the error message
IOError: [Errno13] Permissiuon denied: '/sys/class/gpio/export'

I've built this lovely buffered input/output card but I have yet to get a single line working.

Jochen
If you get that error message then you are using an old version (0.2.0). I suggest you download and install version 0.3.1a as described above Also note that the error message is because you are not running as root.
I must admit that I have no idea whether I am running as root or not - I don't even know what that means. I'm used to systems where you can run your programs from anywhere.

Thanks for the help. I think I shall have to wait until RiscOS becomes more developed.

Jochen

Daverj
Posts: 28
Joined: Tue Mar 06, 2012 2:23 am
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Sun Aug 05, 2012 10:23 pm

Jochen wrote:
croston wrote:
Jochen wrote:I've installed GPIO and all that, but every time I run a program the error message
IOError: [Errno13] Permissiuon denied: '/sys/class/gpio/export'

I've built this lovely buffered input/output card but I have yet to get a single line working.

Jochen
If you get that error message then you are using an old version (0.2.0). I suggest you download and install version 0.3.1a as described above Also note that the error message is because you are not running as root.
I must admit that I have no idea whether I am running as root or not - I don't even know what that means. I'm used to systems where you can run your programs from anywhere.

Thanks for the help. I think I shall have to wait until RiscOS becomes more developed.

Jochen
When you booted up your Raspberry Pi and were asked for a user name, if you entered the default "Pi" name then you are running as the user "Pi". You would have had to log in as user "root" to be running as root. Root is the equivalent of "Administrator" on many other modern operating systems.

It is possible to tell the OS to run your program as if you were root by simply adding "sudo" in front of the program name. For example, if you typed in:

python myprogram.py

and got the error you described above, then simply type in:

sudo python myprogram.py

and you will no longer get that error because you told the system to run that program as if root had run it, instead of the user Pi running it.

When you install an OS like Windows on a computer as a single user system, that user has administrative privileges, so you aren't aware of these kind of restrictions. But if that same OS is installed on a work computer by an IT department they usually create a user account for the employee, and that account does not have administrative privileges, and can not install certain programs or alter the OS in certain ways.

odelcarmen
Posts: 10
Joined: Sat Jul 07, 2012 12:41 pm

Re: RPi.gpio v0.3.1a and Raspbian

Wed Aug 08, 2012 4:47 pm

Please help.

I have my RPi installed with wheezy-raspbian.img,
and downloaded a copy of RPi.GPIO-0.3.1a.tar.gz

then logged in as pi.
from $ prompt, I've ran:

sudo apt-get install python3.2-dev

sudo gunzip RPi.GPIO-0.3.1a.tar.gz
sudo tar -xvf RPi.GPIO-0.3.1a.tar

cd /home/pi/RPi.GPIO-0.3.1a
sudo python3.2 setup.py install

cd /usr/local/lib/python3.2/dist-packages/
sudo easy_install RPi.GPIO-0.3.1a-py3.2-linux-armv6l.egg

either one from the MagPi issue 2's sample python program mybutton.py,
or the downloaded blink.py, or inout.py had been tried
sudo python3.2 mybutton.py
sudo python3.2 blink.py
sudo python3.2 inout.py

but similar to the others here in the forum, the same error is being encountered:

Traceback (most recent call last):
File "<<program.py>>", line 2, in <module>
import RPi.GPIO as GPIO
ImportError: No module named GPIO

I have already refreshed the SD image a couple of times and repeated the sequence above, but still got the same results.

Maybe someone has to (video) capture a successful run (step by step) and post it online so that the newbies and slow-learners like me can learn.

Cheers!

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Wed Aug 08, 2012 6:34 pm

Which distro are you using?

All I can say is that on two Pis with

Our setup is
Raspbian image 2012-07-15-wheezy-raspbian.img
Python 3.2

On one I did

sudo apt-get update
sudo apt-get upgrade

Before what was shown above and all worked.

I used apt-get python3-dev

All the above steps worked twice on fresh installs of

Raspbian image 2012-07-15-wheezy-raspbian.img
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

stevenwiner
Posts: 13
Joined: Wed Jul 11, 2012 7:29 pm
Location: South Africa

Re: RPi.gpio v0.3.1a and Raspbian

Fri Aug 10, 2012 8:51 pm

Using Raspbian image 2012-07-15-wheezy-raspbian.img and followed all the instructions for downloading and installing python3-dev and also downloading and installing RPi.GPIO-0.3.1a.tar.gz

I was getting an error about the mode not set, so added the line:
GPIO.setmode(GPIO.BOARD)

before the line:
import RPi.GPIO as GPIO

I then had the same issues as you- getting error "no module named RPi.GPIO"

I got that error when running the GPIO program with the single switch and LED as described in the MagPi magazine edition 2.

I had saved the file mybutton.py in the /home directory and still had errors.

I then saved in /home/pi directory and suddenly the program works, but only in the command line.

I still get an error in the LDXE GUI telling me I am not running root.

so now in command line I type:

sudo /home/pi/mybutton.py

AND IT WORKS GREAT!!!

Regards

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Fri Aug 10, 2012 10:42 pm

If you look back up there are instructions showing that if you ar logged on as pi user (not root) to run IDLE3 as follows
4/ Using Xwindows graphical interface
Logged on as pi user
Start menu -> Run
type in sudo idle3
press OK
...

If you run idle3 as root by doing "sudo idle3" that should solve the problem
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

xzanfr
Posts: 18
Joined: Wed Jun 20, 2012 12:52 pm

Re: RPi.gpio v0.3.1a and Raspbian

Sun Aug 26, 2012 6:21 pm

Hi all - I've spent the first few days of the bank holiday trying to get this to work! As a total newbie to linux and the pi I've relied on the excellent information on this forum and contributions of you all, and thought that my findings may be of help to other newbies who may be having issues:

(I'm using a new install of wheezy and running the pi headless using tightvnc as described on penguin tutor)

I've installed and followed the instructions as provided by techpaul - it all appeared ok, the instilation was error free and it even worked as described when I ran idle, however it came up with the...

Code: Select all

No module named RPi.GPIO
...when running the mybutton program from magpi.
I've reinstalled everything however this error kept on occuring. In the end it dawned on me that I was running the program using

Code: Select all

sudo python mybutton.py
.. to run mybutton.py.
I changed this to ...

Code: Select all

sudo python3 mybutton.py
and, having added in the extra line...

Code: Select all

GPIO.setmode(GPIO.BOARD)
...as mentioned by stevenwiner it all worked.

It seems obvious but really confused me at first and may also confuse any others in the same position as me - hopefully the above will help out with the completeness of this thread!

Cheers for all your help.

Gary

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: RPi.gpio v0.3.1a and Raspbian

Mon Aug 27, 2012 6:48 am

When I try the gunzip command it says this:


pi@raspberrypi ~ $ gunzip RPi.GPIO-0.3.1a.tar.gz
bash: $'\302\240gunzip': command not found

Why? What am I doing wrong? Do I have to install gunzip or something? Help me!!!!!!!!!!
Just a beginner sharing his experiences on his way to geek nirvana...

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: RPi.gpio v0.3.1a and Raspbian

Mon Aug 27, 2012 11:04 am

@Bigcat123: It means you should not type a non breaking space in front of the `g` of ``gunzip`` because it becomes a part of the name then and there is no command by that name. With non breaking space in front:

Code: Select all

pi@raspberrypi ~ $  gunzip
-bash: $'\302\240gunzip': command not found
Without:

Code: Select all

pi@raspberrypi ~ $ gunzip
gzip: compressed data not read from a terminal. Use -f to force decompression.
For help, type: gzip -h

Code: Select all

while not self.asleep():
    sheep += 1

Return to “Python”