I installed RPi.GPIO .5.1 and my uber basic led code says that the object has no attribute 'output'. I am hooking up the 12 pin to the Breadboard and I have ground hooked up too. Here is my python 2.7.7 code:

import time
import RPi.GPIO as GPIO
Steve Robillard
  • 34,478
  • 17
  • 103
  • 109
  • 13
  • 1
  • 3

2 Answers2


What errors result when you run the script?

Here are a few potential errors I can see:

  • you could use from time import sleep instead of import time
  • you haven't put in the shebang line at the start of the script (#!/usr/bin/env python) - this tells what you are using to run it what it is.
  • You likely don't need GPIO.output(12,GPIO.LOW) as I would of thought that GPIO.output(12,GPIO.HIGH) would override it (you can also use GPIO.output(12, True)
  • With the GPIO.setup(GPIO.OUT) line, I think you need to specify the pin number - so it would be GPIO.setup(12, GPIO.OUT)

Another problem could be that you don't have it wired correctly - you can get help with pin numbers etc here. Try not get confused between the Board and BCM numbering

So something like this should work:

#!/usr/bin/env python
import RPi.GPIO as GPIO
from time import sleep

GPIO.setup(12, GPIO.OUT)

GPIO.output(12, True))
print "On"
print "Off"
GPIO.output(11, False)
  • 2,503
  • 3
  • 21
  • 38
  • How did this solve your problem ? I have the same one and cannot figure out from where this comes from – ypicard Jul 08 '19 at 12:57
  • @ypicard what error - "*has no attribute 'output'.*" ? I guess it could the the extra `)` in the code above otherwise... – Wilf Jul 10 '19 at 17:41

This error 'module' object has no attribute 'output' means that the library which can access GPIO is not installed in it so, open your terminal

type: $ sudo apt-get install python-rpi.gpio python3-rpi.gpio

and then run your program if any warning occurs then add GPIO.setwarnings(False) to your code

  • 2,631
  • 3
  • 15
  • 20
  • 1
    `the library which can access GPIO is not installed in it ` if that is the case then why does the script not crash at import or the calls to setmode and setup. Anyway, the previous answer was accepted as an answer so it apparently solved the problem. – Dirk Jan 09 '19 at 19:41