Looks to me like a device permission issue. I suspect that chmod on /dev/usb won't do what you want. Some distros have a usb group that you can add your user to. I usually end up setting up a udev rule, though.

My best guess on the root/sudo thing is your user's site-packages aren't being read while running as root, so it doesn't think you have pyusb installed at all. Could run pip as root to install pyusb.

Best,
Jeff
On 1/21/2019 4:28 PM, charles wilson wrote:
Hi Jacques, the type of device makes no difference I have tried with range of devices, keyboard, usb HDD, robotic interface .... all with the same results

Cheers
Charles

On Mon, 21 Jan 2019 at 19:34, Jacques-D. Piguet <jacques.pig...@bluewin.ch <mailto:jacques.pig...@bluewin.ch>> wrote:

    Hi Charles,

    What kind of device are you trying to communicate with?

    Regards, Jacques-D.


    On 21.01.19 05:23, charles wilson wrote:
    Hi Guys,
    Thanks for your time and feedback; it's taken awhile to get back
    to this.
    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

    pi@raspi3:~/.local/lib/python3.5/site-packages/usb
    <mailto:pi@raspi3:~/.local/lib/python3.5/site-packages/usb> $ ls -l
    total 132
    drwxrwxrwx 3 pi pi  4096 Jan 20 13:31 backend
    -rwxrwxrwx 1 pi pi  8739 Jan 20 13:31 control.py
    -rwxrwxrwx 1 pi pi 46704 Jan 20 13:31 core.py
    -rwxrwxrwx 1 pi pi  3215 Jan 20 13:31 _debug.py
    -rwxrwxrwx 1 pi pi  3550 Jan 20 13:31 __init__.py
    -rwxrwxrwx 1 pi pi  3522 Jan 20 13:31 _interop.py
    -rwxrwxrwx 1 pi pi 12588 Jan 20 13:31 legacy.py
    -rwxrwxrwx 1 pi pi  6788 Jan 20 13:31 libloader.py
    -rwxrwxrwx 1 pi pi  3259 Jan 20 13:31 _lookup.py
    -rwxrwxrwx 1 pi pi  5287 Jan 20 13:31 _objfinalizer.py
    drwxrwxrwx 2 pi pi  4096 Jan 20 13:31 __pycache__
    -rwxrwxrwx 1 pi pi 12291 Jan 20 13:31 util.py

    pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend
    <mailto:pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend>
    $ ls -l
    total 108
    -rwxrwxrwx 1 pi pi 16048 Jan 20 13:31 __init__.py
    -rwxrwxrwx 1 pi pi 23783 Jan 20 13:31 libusb0.py
    -rwxrwxrwx 1 pi pi 35299 Jan 20 13:31 libusb1.py
    -rwxrwxrwx 1 pi pi 28019 Jan 20 13:31 openusb.py
    drwxrwxrwx 2 pi pi  4096 Jan 20 13:31 __pycache__
    pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend
    <mailto:pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend>
    $ cd  __pycache__
    pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend/__pycache__
    
<mailto:pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend/__pycache__>
    $ ls -l
    total 76
    -rwxrwxrwx 1 pi pi 16140 Jan 20 13:31 __init__.cpython-35.pyc
    -rwxrwxrwx 1 pi pi 15006 Jan 20 13:31 libusb0.cpython-35.pyc
    -rwxrwxrwx 1 pi pi 23713 Jan 20 13:31 libusb1.cpython-35.pyc
    -rwxrwxrwx 1 pi pi 18216 Jan 20 13:31 openusb.cpython-35.pyc
    pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend/__pycache__
    
<mailto:pi@raspi3:~/.local/lib/python3.5/site-packages/usb/backend/__pycache__>
    $

    still get the same error diagnostic which still ends
    usb.core.USBError: [Errno 13] Access denied (insufficient
    permissions)"
    Traceback (most recent call last):
      File "/home/pi/usb1.py", line 12, in <module>
        dev.set_configuration()
      File "/home/pi/.local/lib/python3.5/site-packages/usb/core.py",
    line 869, in set_configuration
        self._ctx.managed_set_configuration(self, configuration)
      File "/home/pi/.local/lib/python3.5/site-packages/usb/core.py",
    line 102, in wrapper
        return f(self, *args, **kwargs)
      File "/home/pi/.local/lib/python3.5/site-packages/usb/core.py",
    line 147, in managed_set_configuration
        self.managed_open()
      File "/home/pi/.local/lib/python3.5/site-packages/usb/core.py",
    line 102, in wrapper
        return f(self, *args, **kwargs)
      File "/home/pi/.local/lib/python3.5/site-packages/usb/core.py",
    line 120, in managed_open
        self.handle = self.backend.open_device(self.dev)
      File
    "/home/pi/.local/lib/python3.5/site-packages/usb/backend/libusb1.py",
    line 786, in open_device
        return _DeviceHandle(dev)
      File
    "/home/pi/.local/lib/python3.5/site-packages/usb/backend/libusb1.py",
    line 643, in __init__
        _check(_lib.libusb_open(self.devid, byref(self.handle)))
      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)
    so basically no change.

    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.

    The further I go with this the darker the tunnel gets.

    Cheers
    Charles

    On Sat, 19 Jan 2019 at 09:23, Sergio A. Quiroga
    <sergioa.quir...@gmail.com <mailto:sergioa.quir...@gmail.com>> wrote:

        i saw this message:

            usb.core.USBError: [Errno 13] Access denied (insufficient
permissions)

        when i was using a wrong driver in Windows 10. I could also
        see the whole usb device descriptor, just could not interact
        with it.

        my suggestion is to try to re install or update the libusb driver

        On Thu, Jan 17, 2019 at 9:01 PM charles wilson
        <cmf.wil...@gmail.com <mailto:cmf.wil...@gmail.com>> wrote:

            Hi,
            I usually manage to solve my problems by hitting my head
            against them until I get a breakthrough. This time nothing.
            I am new to trying PYUSB. I have the same problem with 2
            installations.
            1) Ubuntu Mate 16.04 on Kernel Linux 4.15.0-43-generic
            x86_64running on AMD Ryzen 5 2600X
            2) Raspbian (Jessie) on Raspberry Pi 3B+

            Also I confirm that libusb-1.0-0
            <https://pkgs.org/download/libusb-1.0-0> is there on both.

            After installation I started the tutorial (why not?) but
            did not get far:

            import usb.core
            import usb.util

            dev = usb.core.find(idVendor=0x1d6b, idProduct=0x0003)
            print(dev)
            /OK so far and I get:/
            /
            ================== RESTART:
            /home/wilson/temPY/USBtest01.py ==================
            DEVICE ID 1d6b:0003 on Bus 004 Address 001 =================
             bLength                : 0x12 (18 bytes)
             bDescriptorType        : 0x1 Device
             bcdUSB                 : 0x300 USB 3.0
             bDeviceClass           : 0x9 Hub
             bDeviceSubClass        : 0x0
             bDeviceProtocol        : 0x3
             bMaxPacketSize0        : 0x9 (9 bytes)
             idVendor               : 0x1d6b
             idProduct              : 0x0003
             bcdDevice              : 0x415 Device 4.15
             iManufacturer          : 0x3 Error Accessing String
             iProduct               : 0x2 Error Accessing String
             iSerialNumber          : 0x1 Error Accessing String
             bNumConfigurations     : 0x1
              CONFIGURATION 1: 0 mA ====================================
               bLength              : 0x9 (9 bytes)
               bDescriptorType      : 0x2 Configuration
               wTotalLength         : 0x1f (31 bytes)
               bNumInterfaces       : 0x1
               bConfigurationValue  : 0x1
               iConfiguration       : 0x0
               bmAttributes         : 0xe0 Self Powered, Remote Wakeup
               bMaxPower            : 0x0 (0 mA)
                INTERFACE 0: Hub =======================================
                 bLength            : 0x9 (9 bytes)
                 bDescriptorType    : 0x4 Interface
                 bInterfaceNumber   : 0x0
                 bAlternateSetting  : 0x0
                 bNumEndpoints      : 0x1
                 bInterfaceClass    : 0x9 Hub
                 bInterfaceSubClass : 0x0
                 bInterfaceProtocol : 0x0
                 iInterface         : 0x0
                  ENDPOINT 0x81: Interrupt IN ==========================
                   bLength          : 0x7 (7 bytes)
                   bDescriptorType  : 0x5 Endpoint
                   bEndpointAddress : 0x81 IN
                   bmAttributes     : 0x3 Interrupt
                   wMaxPacketSize   : 0x4 (4 bytes)
                   bInterval        : 0xc
            /
            /
            /
            which tells me that pyusb is installed and is finding
            USB.core and seems to be working.
            When I take the next step in the tutorial:
            dev.set_configuration()

            it all turns to custard and I get:

            raceback (most recent call last):
              File "/home/wilson/temPY/USBtest01.py", line 11, in
            <module>
                dev.set_configuration()
              File "/usr/lib/python3/dist-packages/usb/core.py", line
            799, in set_configuration
            self._ctx.managed_set_configuration(self, configuration)
              File "/usr/lib/python3/dist-packages/usb/core.py", line
            127, in managed_set_configuration
                self.managed_open()
              File "/usr/lib/python3/dist-packages/usb/core.py", line
            105, in managed_open
                self.handle = self.backend.open_device(self.dev)
              File
            "/usr/lib/python3/dist-packages/usb/backend/libusb1.py",
            line 722, in open_device
                return _DeviceHandle(dev)
              File
            "/usr/lib/python3/dist-packages/usb/backend/libusb1.py",
            line 600, in __init__
            _check(_lib.libusb_open(self.devid, byref(self.handle)))
              File
            "/usr/lib/python3/dist-packages/usb/backend/libusb1.py",
            line 552, in _check
                raise USBError(_strerror(ret), ret, _libusb_errno[ret])
            usb.core.USBError: [Errno 13] Access denied (insufficient
            permissions)

            This on the AMD system, the diagnostic on the Raspi is
            similar but not identical.

            I have worked through the other similar postings on the
            mailing list - while similar their problems were at a
            more complex level --- I am at step 1 with the tutorial ...
            I have also worked through the occurrences of
            set_configuration() in the ...usb/core.py module and
            could see no reason for dev.set_configuration() to bomb-out.

            I have racked my brains and consulted my local gurus with
            no joy .... so any help would be appreciated - I have a
            feeling it is something dumb that I have missed.

            Cheers
            Charles



            _______________________________________________
            pyusb-users mailing list
            pyusb-users@lists.sourceforge.net
            <mailto:pyusb-users@lists.sourceforge.net>
            https://lists.sourceforge.net/lists/listinfo/pyusb-users



-- SQ
        _______________________________________________
        pyusb-users mailing list
        pyusb-users@lists.sourceforge.net
        <mailto:pyusb-users@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/pyusb-users




    _______________________________________________ pyusb-users
    mailing list pyusb-users@lists.sourceforge.net
    <mailto:pyusb-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/pyusb-users

    _______________________________________________
    pyusb-users mailing list
    pyusb-users@lists.sourceforge.net
    <mailto: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



_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to