Raspberry Pi for Dummies. Page 49

Line 7 GPIO.setmode(GPIO.BCM)

error: NameError: name GPIO is not defined

we've checked it's definately the letter 'O' not a zero. Either the code isn't right or the import RPi.GPIO isn't correct.

`we tried python and python3

Any ideas?

  • Post the code you are attempting to run together with the actual error message (cut & paste).
    – joan
    Commented Jan 10, 2017 at 14:00
  • 1
    Hi Jack :) Welcome to Pi Q&A - Technically - If one of the answers, answered your question - you should have up voted it and accepted it (I understand you may not have had enough rep to accept it - I don't get that but yea) Please accept an answer if you can.. and don't be shy with up votes :D Good luck and see you around.
    – Piotr Kula
    Commented Jan 10, 2017 at 14:27

2 Answers 2


I am not sure what the full example looks like but ti should look like this.

#external module imports
import RPi.GPIO as GPIO

#pin setup
  • the issue was as GPIO missing. Thanks, it works now!
    – Jack
    Commented Jan 10, 2017 at 14:11

You are not providing all your code, so I'm not sure what you have imported, however, after doing

import RPi.GPIO as GPIO

the statement


should work. If you forgot the as GPIO part, it would still work but you'd have to type


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.