I looked everywhere for answers and non worked, hopefully i will have someone who can help me, simply I want to turn on and turn off a led and I have this code >

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) # set board mode to Broadcom 
GPIO.setup(7,GPIO.OUT) # set up pin 7
for x in range(0,10):

and when I run i get this >

========================= RESTART: /home/pi/blink.py =========================
Traceback (most recent call last):
  File "/home/pi/blink.py", line 1, in <module>
    import RPi.GPIO as GPIO
ImportError: No module named 'RPi.GPIO'

I am using Python (IDLE) V 3.5.3

3 Answers 3


You didn't mentioned what OS distro you are using. But if you are using Raspbian Stretch, RPi.GPIO is included in default installation of Python 2.7, but it does not seems to be included in Python 3.5 by default, you will probably have to install it either running:

sudo apt-get install python3-rpi.gpio

or if you have pip3 installed,

pip3 install RPi.GPIO

as mentioned at https://stackoverflow.com/a/70863758/4870357 and https://stackoverflow.com/a/73913361/4870357

For me was need to focus on using python3 with permission of sudo so rember to use sudo with python3

sudo python3 filename.py

and maybe need to active SPI by run through Terminal:

sudo raspi-config


Interface Options > SPI then make sure to be activated/enabled


This didn't help: pip3 install RPi.GPIO

This fixed it: sudo apt install python3-rpi.gpio

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.