Allen E
Posts: 3
Joined: Sat Jun 08, 2013 1:08 am

GPIO only works for me on python3

Sun Jun 30, 2013 8:15 pm

When I try to run the sample programs for GPIO, I get the message " GPIO.setmode(GPIO.BCM) AttributeError: 'module' object has no attribute 'setmode'.
When I do a dir or help on the module it only shows :
>>> dir(GPIO) ['IN', 'InvalidDirectionException', 'InvalidPinException', 'OUT', 'WrongDirectionException', '_ExportedIds', '_GPIO_PINS', '_GetValidId', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '_unexport', 'atexit', 'input', 'os', 'output', 'setup']

I have removed and re-installed Python-dev and the GPIO update with no help.
However, I have installed Python 3 and am able to get the GPIO module working properly there.

I downloaded the RPi.GPIO bundle directly from https://pypi.python.org/pypi/RPi.GPIO, unpacked it and loaded it for both python and python3 using the install script provided.
python3 worked, but python still didn't support the functions required.

Here is the python3 dir result:
['ALT0', 'BCM', 'BOARD', 'BOTH', 'FALLING', 'HIGH', 'IN', 'LOW', 'OUT', 'PUD_DOWN', 'PUD_OFF', 'PUD_UP', 'PWM', 'RISING', 'RPI_REVISION', 'VERSION', '__doc__', '__file__', '__name__', '__package__', 'add_event_callback', 'add_event_detect', 'cleanup', 'event_detected', 'gpio_function', 'input', 'output', 'remove_event_detect', 'setmode', 'setup', 'setwarnings', 'wait_for_edge']

I've run up updates and re-installed, but no luck.

It's probably something really simple, but I don't have a clue at this point.. Anyone have any suggestions?

User avatar
croston
Posts: 708
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: GPIO only works for me on python3

Sun Jun 30, 2013 9:27 pm

You probably still have an old version of RPi.GPIO lying around that you manually installed a while ago.
To find out, what is the result of:

Code: Select all

$ find /usr | grep -i GPIO

Allen E
Posts: 3
Joined: Sat Jun 08, 2013 1:08 am

Re: GPIO only works for me on python3

Tue Jul 02, 2013 7:43 am

croston wrote:You probably still have an old version of RPi.GPIO lying around that you manually installed a while ago.
To find out, what is the result of:

Code: Select all

$ find /usr | grep -i GPIO
Makes sense... I'll check that out. thanks!

Allen E
Posts: 3
Joined: Sat Jun 08, 2013 1:08 am

Re: GPIO only works for me on python3

Thu Jul 04, 2013 2:26 am

I took the coward's way out and just re-installed the o/s. I'm sure that I got in a position trying to solve this where I'd gotten an older version of RPi.GPIO.

thanks for the assistance!

Return to “General discussion”