1

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):
    GPIO.output(7,True)
    time.sleep(2)
    GPIO.output(7,False)
    time.sleep(2)

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

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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