romilly/quick2wire-python-api

OSError

Closed this issue · 2 comments

Hi,

I hope I'm posting in the right place...

I'm totally newbie in python (but not in programming). I've created a test to use quick2wire python api but get an error message. My (reduced) source code is :

!/usr/bin/python3

from time import sleep
from quick2wire.gpio import Pin
pins = [Pin(n,Pin.Out) for n in [7, 22, 18, 16, 15, 13, 12, 11]]

When I execute it, i get an error message for the last line :

Traceback (most recent call last):
File "./test2.py", line 6, in
pins = [Pin(n,Pin.Out) for n in [7, 22, 18, 16, 15, 13, 12, 11]]
File "./test2.py", line 6, in
pins = [Pin(n,Pin.Out) for n in [7, 22, 18, 16, 15, 13, 12, 11]]
File "/home/pi/python_GPIO/quick2wire-quick2wire-python-api-623e5fe/src/quick2wire/gpio.py", line 88, in init
self.export()
File "/home/pi/python_GPIO/quick2wire-quick2wire-python-api-623e5fe/src/quick2wire/gpio.py", line 110, in export
gpio_admin("export", self.pin_id)
File "/home/pi/python_GPIO/quick2wire-quick2wire-python-api-623e5fe/src/quick2wire/gpio.py", line 47, in gpio_admin
subprocess.check_call(["gpio-admin", subcommand, str(pin)])
File "/usr/lib/python3.1/subprocess.py", line 429, in check_call
retcode = call(_popenargs, *_kwargs)
File "/usr/lib/python3.1/subprocess.py", line 416, in call
return Popen(_popenargs, *_kwargs).wait()
File "/usr/lib/python3.1/subprocess.py", line 646, in init
errread, errwrite)
File "/usr/lib/python3.1/subprocess.py", line 1157, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

I've thus tried a "sudo ./test2.py" but got then a "no module named quick2wire.gpio..." error.

any idea about how to solve it?

Have you installed gpio-admin and added yourself to the gpio group, as described in the gpio-admin README file? See https://github.com/quick2wire/quick2wire-gpio-admin. In particular, you must log out and back in again after adding yourself to the gpio group for the change to take effect. That's the way Linux works and we can't do anything about that to make the process smoother I'm afraid. But after that first log-out/log-in the group membership will active.

Thanks for this usefull answer! I was sure I added my username to gpio group but it seems that I made a mistake somewhere. Now fixed. Thanks again.