I have installed RPi.GPIO and can import it into a python script fine without a error but as soon as i try to manipulate any of the gpio's i always get a error saying
file "practice.py" line 5 in <module>
GPIO.setmode(GPIO.BOARD)
AttributeError: 'module' object has no attibute 'setmode'
my code is
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
my version of RPi.GPIO is .o.5.4 the latest one i believe.
i have looked everywhere on the internet for a solution on what I'm doing wrong please help me :(
2 Answers 2
It was a issue with how I downloaded RPi.GPIO.
I tried to download it myself through the internet, following a tutorial on youtube.
What I did was just find a tutorial on installing it from the command line.
Instead, there is another video on youtube that talks you through all the different ways of using the gpio ports and RPi.GPIO is one of them.
Any future people with this problem I would suggest installing it from the terminal/shell.
Is this the only script you've tried? I turn off my fish light with the following code called from CRON:
import RPi.GPIO as GPIO
import time
print "Turning off fish light"
GPIO.setmode(GPIO.board)
GPIO.setup(18,GPIO.out)
GPIO.output(18,False)
time.sleep(2)
GPIO.cleanup()
I'm sure you have the right permissions for this - you can't do GPIO stuff unless you're root or root-like (Is that a word?) e.g sudo python fishoff.py. What's the rest of your code?