Open main menu

Changes

How to Install RPi.GPIO Python Library

42 bytes added, 20:56, 16 June 2023
no edit summary
__NOTOC__
 
The RPi.GPIO Python library allows you to easily configure and read-write the input/output pins on the Pi’s GPIO header within a Python script. Thankfully this library is now including in the standard Raspbian image available from the [https://www.raspberrypi.com/software/ Foundations Download Page].
If you are using a fresh image you don’t need to install it but I’ve kept the instructions here in case you ever want to try a manually installation.<ref>https://www.raspberrypi-spy.co.uk/2012/05/install-rpi-gpio-python-library/</ref>
==== Method 1 – Install from repository ====
If the package exists in the Raspbian repository is can be installed using apt-get. First you need to update the available package versions :Refer to [https://www.raspberrypi-spy.co.uk/2012/05/install-rpi-gpio-python-library/ Install RPi.GPIO Python Library]
sudo apt-get update
==== Method 2 – Manual Installation ====
The package is available from '''http://pypi.python.org/pypi/RPi.GPIO ''' and the current version is 0.7.1 (Feb 6, 2022). '''If this version is updated you will need to make appropriate changes to the version number in the commands below'''. '''Step 1 – Download the library'''
===== Step 1 – Download the library ===== wget https://files.pythonhosted.org/packages/c4/0f/10b524a12b3445af1c607c27b2f5ed122ef55756e29942900e5c950735f2/RPi.GPIO-0.7.1.tar.gz
'''Step 2 – Extract the archive to a new folder'''
tar -xvf RPi.GPIO-0.7.1.tar.gz
'''===== Step 3 – Browse to the new directory'''=====
cd RPi.GPIO-0.7.1
'''===== Step 4 – Install the library'''=====
sudo python setup.py install
'''===== Step 5 – Remove the directory and archive file'''=====
cd ~
sudo rm -rf RPi.GPIO-0.*
This will now mean you can use the library within Python.
 '''===== Example Usage'''=====
‎<syntaxhighlight lang="python" line >
import RPi.GPIO as GPIO
GPIO.output(18, GPIO.HIGH)
‎</syntaxhighlight>
 
==References==
<references />
 
 
<!--Add review function! -->