Hi Tormod & others Looks we are the same page ... yes I will tidy up permissions later ... and the issue relates to the python version. I downloaded pyusb not python-usb"or "python3-usb.
But I am winning!!!!! yes although still need help. My process has been as follows (bear in mind I have the same problem with my raspbian & ubuntu 16.04 systems - I am working on the Raspberry Pi because it is way easier to reinstall the OS than on my desktop :) Script: 1 2 import usb.core 3 import usb.util 4 help()usb) 5 dev = usb.core.find() 6 print(dev) 7 8 dev.set_configuration() lines 4,5 and 6 execute fine = I get the expected outcome Diagnostic: AS it only the last line that really matters: File "/home/pi/.local/lib/python3.5/site-packages/usb/backend/libusb1.py", line 595, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 13] Access denied (insufficient permissions) Check permissions: pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend $ ls -l total 108 ... the relevant one is: -rwxrwxrwx 1 pi pi 35299 Jan 20 13:31 libusb1.py ... so anyone can execute ???? ... so if I run libusb1.py in idle I get: File "/home/pi/.local/lib/python3.5/site-packages/usb/backend/libusb1.py", line 702, in <module> class _LibUSB(usb.backend.IBackend): AttributeError: module 'usb' has no attribute 'backend' ... so it looks like the permission problem = no backend ... but if I root@raspi3:/home/pi/.local/lib/python3.5/site-packages/usb/backend# python3.5 libusb1.py Traceback (most recent call last): File "libusb1.py", line 30, in <module> import usb.util ImportError: No module named 'usb' in module libusb1.py: 29 from ctypes import * 30 import usb.util so it seems the permission that is failing is the ability of backend to import usb.util which my script does not seem to have a problem with. Now checking ctypes there are three copies at: i) /usr/lib/python2.7/ctypes ii) /usr/lib/pypy/lib-python/2.7/ctypes iii) /usr/lib/python3.5/ctypes permissions on the above are all ok ... now it gets interesting ... if I run (in idle) the script copied from libusb1.py: from ctypes import * import usb.util .... and add help(usb.util) I get expected 'help' output. so there is a difference. BUT .. idle is python3.5 and pyusb is only installed in python3.5 ... which usb.util does libsub1.py call? Am I on the right track here? I have now installed pyusb via pip to python2.7 ... my script now runs iin terminal as user!!! looks like a win! checking with ~$ python --version it seems the system defaults to 2.7 I have installed pyusb to 2.7 ... and checked it is there permissions are ok plus IDLE for 2.7 Now I need more help. While I can run the script from the terminal I can't from my IDEs I still get File "/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 595, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) USBError: [Errno 13] Access denied (insufficient permissions) which I would understand if it is run from 3.5,but this is from 2.7???? cheers Charles On Tue, 22 Jan 2019 at 11:16, Tormod Volden <lists.tor...@gmail.com> wrote: > On Mon, Jan 21, 2019 at 5:28 AM charles wilson wrote: > > On permissions, I had checked/changed permissions previously but > re-checked and found a missed one in /python3.5/site-packages/usb/backend- > happened to be libusb1.pywhich was flagged - all fixed now > > > I had also not checked the /dev/*USB* but did and gave necessary > permissions > > > drwxrwxrwx 3 pi pi 4096 Jan 20 13:31 backend > > -rwxrwxrwx 1 pi pi 8739 Jan 20 13:31 control.py > > still get the same error diagnostic which still ends usb.core.USBError: > [Errno 13] Access denied (insufficient permissions)" > > > so basically no change. > > Charles, > > The permission issue is with the USB device node under > /dev/bus/usb/*/* and not the python library files. It looks like you > have messed up all library files permissions now - they need not and > should not be writeable for everybody. You'd better reinstall the > packages to tidy up. > > > > > Now the interesting bit. I tried running as root > > root@raspi3:/home/pi/PyProj# python3.5 pyusb_1.py > > Traceback (most recent call last): > > File "pyusb_1.py", line 2, in <module> > > import usb.core > > ImportError: No module named 'usb' > > > > same result if I simply sudo python3.5 pyusb_1.py > > > > when I run python3.5 from the terminal and get the python >>> prompt > there is no trouble with 'import' and checking with 'help(usb)' shows the > module is there and accessible. > > > > Interesting though is that I have the same problem on all linux, so > whatever I did wrong I did it each time. I have tried installing pyusb with > PIP and sudo apt-get but it makes no difference. > > Note that your Raspberry Pi has both python 2 and python 3 installed. > The Debian package "python-usb" is for Python 2 and the package > "python3-usb" is for Python 3. > > Regards, > Tormod > > > _______________________________________________ > pyusb-users mailing list > pyusb-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pyusb-users >
_______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users