$bw = mobile_device(override_mobile_view()) ? "width:618px;" : ""; ?>
03/30/2018 (8783x read)
Raspberry Pi: Python error „ImportError: No module named ‚RPi’“
03/30/2018 (8783x read)
If you want to use the Raspberry Pi mini-computer with it’s programminglanguage Python to access the Pi’s GPIO ports you first have to make sure that all needed Python libraries are installed. If an important library is missing, you’ll get the „ImportError“ – like the „ImportError: No module named ‚RPi’“ or „ImportError: No module named ‚RPi.GPIO’“ if the library for the GPIO ports is not installed yet.
Don’t worry, that’s easy to solve – just log into your Raspberry Pi and make an update:
sudo apt-get update
Afterwards you can install the RPi.GPIO library for Python:
sudo apt-get install python-rpi.gpio
If you want to use the module with Python3, you need to install it like this:
sudo apt-get install python-rpi.gpio python3-rpi.gpio
Now your Python code should run without the error message „ImportError: No module named ‚RPi.GPIO’“!