2

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 :(

asked Jan 4, 2014 at 13:48

2 Answers 2

1

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.

RPiAwesomeness
3,0214 gold badges32 silver badges52 bronze badges
answered Jan 5, 2014 at 18:19
0

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?

answered Jan 4, 2014 at 23:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.