15

I downloaded RPi.GPIO 5.3a from here: https://pypi.python.org/pypi/RPi.GPIO

I extracted the tar file, cd into the folder and ran:

sudo python setup.py install

It ran through a bunch of stuff and doesn't seem to have failed. The last line of its work is this:

Writing /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.5.3a.egg-info

After that it was done and gave me back control.

Now I type

sudo python

then

import RPi.GPIO

and I see

ImportError: No module named GPIO

Can anyone point me to exactly what steps I need to take to get the python GPIO library installed correctly so I can import it and manipulate the GP pins? I've found a mish mash of different processes online (this was the one that came up most often) but I have thus far been unable to get any of them to work.

23

Not sure if this is helpful, but under the latest copy of Raspbian I was able to install RPi.GPIO directly from the main repositories using apt-get as follows:

sudo apt-get update
sudo apt-get -y install python-rpi.gpio

If you're running Python 3 (idle3 on the command line) instead of Python 2 (python on the command line) you need to install the RPi.GPIO library with this command instead:

sudo apt-get -y install python3-rpi.gpio
8

Assuming you have pip, the python package index installer, which is installed on the latest versions of Raspbian by default You can use: sudo pip install RPi.GPIO for Python 2 and sudo pip-3.2 install RPi.GPIO for Python 3

4

Another potential cause could be because the RPi.GPIO library has C bindings and therefore need to have python-dev installed in order to compile correctly when installing.

Make sure you've got the python-dev package installed along with the RPi.GPIO package:

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

This is the recommended approach on the Adafriuit installation guide:

https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/install-python-module-rpi-dot-gpio

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.