1

I am developing a small usb application using python (pyUSB) under Win 10 and have the following problem.

When I test basic commands under the python console, everything works fine. I can open the device, write bytes to it and read from it.

Next, I am trying to put it all in one tkinter app and debug it using VSCode. Here I keep getting the following error:

File "c:\Test\usbtester\main.py", line 198, in usb_open
    self.dev.set_configuration()
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\core.py", line 869, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\core.py", line 147, in managed_set_configuration
    self.managed_open()
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\core.py", line 120, in managed_open
    self.handle = self.backend.open_device(self.dev)
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\backend\libusb1.py", line 787, in open_device
    return _DeviceHandle(dev)
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\backend\libusb1.py", line 644, in __init__
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
  File "c:\Program Files\Python37\usbtenv\lib\site-packages\usb\backend\libusb1.py", line 596, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

Can someone suggest what I could be doing wrong here?

ACBlue
  • 71
  • 1
  • 7
  • Have you created the rules file? You can look for https://stackoverflow.com/questions/50625363/usberror-errno-13-access-denied-insufficient-permissions and https://github.com/braiden/python-ant-downloader/issues/30 to get some inspiration. – Steven-MSFT Jul 23 '20 at 03:01
  • Hi, how do I do that under Windows? Like I have said above, it works from the console, just not when I debug it using vscode. i am guessing this is something related to how VSCode executes the code. – ACBlue Jul 23 '20 at 10:41
  • It looks like when you run it directly in the console you needn't the permission, but when you put it in a tkinter, you need to add the permission rules. – Steven-MSFT Jul 24 '20 at 02:22
  • 1
    Hi, once again, any idea about how to do it or if it can be done under Windows? – ACBlue Jul 28 '20 at 08:49
  • Did you found any way to do this? – Animesh Sahu Jun 08 '21 at 11:04
  • Are you working under Linux or Windows? Are you also using Tkinter? – ACBlue Jun 11 '21 at 12:56

0 Answers0