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


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.

  • 429
  • 1
  • 5
  • 10

5 Answers5


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
Morgan Courbet
  • 3,703
  • 3
  • 21
  • 37
  • 1,497
  • 10
  • 11

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

  • 161
  • 2
  • 7

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:


  • 161
  • 1
  • 2

If you are using a fresh image you don’t need to install it.

For the old version

  1. sudo apt-get update
  2. sudo apt-get install rpi.gpio
  • 11
  • 1

This worked for me on my RPi 4B. Just ensure you have the last version of RPi.GPIO but installed from pip (it was newer) than apt-get:

Remove current RPi.GPIO versions:

sudo apt-get purge python{,3}-rpi.gpio

Update pip first:

sudo -H pip2 install --upgrade pip
sudo -H pip3 install --upgrade pip

Install RPi.GPIO from updated pip:

python -m pip install RPi.GPIO
python3 -m pip install RPi.GPIO
  • There is NO NEED to install `RPi.GPIO` the latest version is included in *Raspberry Pi OS* and if you need to reinstall use the version in the repository. All you have achieved is resurrecting an obsolete post. – Milliways Jan 14 '21 at 11:36
  • But it might be useful for people that are not running Raspberry Pi OS. In my case, I was running Ubuntu for full ROS compatibility and I needed RPi.GPIO. – Josep Clotet Ginovart Jan 16 '21 at 10:43
  • @JosepClotetGinovart This sollution that you have posted resolved my problem. Thanks to you Bro – Amin Rostami Nov 01 '22 at 11:50