python-gpio
The latest distribution of the RasPi comes with python-gpio
installed, but this library will be necessary for those who have an old distribution installed. The python-gpio
library allows you to easily access and control the GPIO pins while running the Python script. This library can be downloaded from the Python organization's website, but we will install it using the LXTerminal or PuTTY. Let's proceed by downloading the .tar
file:
wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.7.tar.gz
If you aren't aware, let me tell you that a TAR file is a kind of bundled file used to make the download compact and easy. We need to extract the downloaded file in a directory:
tar -xf RPi.GPIO-0.5.7.tar.gz
Let's rename this folder for ease of use; use this command:
mv RPi.GPIO-0.5.7 python_gpio
Move to the python-gpio
directory to install the library using this command:
cd python_gpio
Tip
While writing a command, you can use the Tab key, which provides an autocompletion feature. For example, while writing the cd pyth
command, press Tab. This will autocomplete the command, which will save the time spent on long filenames. Pressing the Tab key twice will give you a list of the available commands or filenames.
Now, we will install this library:
sudo python setup.py install
There is a possibility that it gives you a response that the library is already installed with the latest version. After this process, if you want to remove the downloaded file, you can use the rm
command and remove it. Finally, one more library that provides support for the Python
Serial Peripheral Interface (SPI) protocol on GPIO is spidev
. You can install it using the following command. You can refer to the Serial Peripheral Interface section of Chapter 2, Meeting the World of Electronics, to learn more on SPI protocol. We will be using the SPI protocol in Chapter 6, Uploading Data Online – Spreadsheets, Mobile, and E-mails, when we build the sensor station project to send sensor data on web pages.
sudo pip install spidev
Tip
There are many libraries available, but we will install them later in the upcoming chapters, when the need arises. It is simple to install the libraries, why wouldn't it be? Linux rocks!