How to Install the GPIO Python Library
If you wish to create a program in Python that utilises the GPIO port on your Raspberry Pi then you'll need to install this library. The RPi.GPIO Python library allows you to easily configure and read-write the input/output pins on the GPIO header within a Python script. There are several GPIO Python libraries available but we recommend you use the one found at http://pypi.python.org/pypi/RPi.GPIO. Although it is possible to download the library through a web browser it's much faster to do the installation process through the terminal on your raspberry pi. At the time of writing the current version of the library is 0.5.3a.
1. Open a terminal window on your raspberry pi and type the following to download the library to your home directory. If a newer version has been released replace the version number with the current version:
2. Extract the contents of the downloaded file:
tar xvzf RPi.GPIO-0.5.3a.tar.gz
3. Change to the newly created directory, again remember to change the version number to that of the version you downloaded.
4. Install the library into Python
sudo python setup.py install
5. Remove the directory and its contents
sudo rm -rf RPi.GPIO-0.5.3a/
6. Delete the archive file
GPIO library is now installed in python, but it won't be loaded by default. To use GPIO library in python start your program with Rpi.GPIO as GPIO at the top. A simple example of programming the GPIO port in Python can be found here.