question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Libusb1 entity not found error

See original GitHub issue

I am having an issue with libusb1 backend throwing an entity not found error. I’m using 64 bit Windows 10 Version 10.0.19042 Build 19042 with 32 bit python 3.9.7 and pyusb version 1.2.1. I am constrained to the legacy usb. When I use usb.core.find(find_all=True) I do not run into this issue. I have included my logging output below.

Z:code\>python
Python 3.9.7 (default, Sep 16 2021, 16:58:32) [MSC v.1916 32 bit (Intel)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['LIBUSB_DEBUG'] = "4"
>>> os.environ['PYUSB_DEBUG'] = "debug"
>>> import usb
>>> [x for x in usb.busses()]
2021-10-12 15:03:49,746 DEBUG:usb.backend.libusb1:_LibUSB.__init__(<WinDLL 'C:\Windows\system32\libusb-1.0.dll', handle 53b70000 at 0x1e780e8>)
2021-10-12 15:03:49,762 INFO:usb.core:find(): using backend "usb.backend.libusb1"
2021-10-12 15:03:49,762 DEBUG:usb.backend.libusb1:_LibUSB.enumerate_devices()
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E90D0>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E91A8>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E9310>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E9478>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E9538>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E95E0>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E96A0>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E9760>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E9820>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E98E0>)
2021-10-12 15:03:49,778 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E99A0>)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x037E9A60>)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_endpoint_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_endpoint_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 1, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0, 1, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E9268>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_endpoint_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0, 1, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 1, 0, 0)
2021-10-12 15:03:49,793 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_endpoint_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0, 1, 0, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 1, 0, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 1, 1, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 2, 0, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_endpoint_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0, 2, 0, 0)
2021-10-12 15:03:49,809 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 2, 0, 0)
2021-10-12 15:03:49,817 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,817 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 2, 1, 0)
2021-10-12 15:03:49,817 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E93B8>, 0)
2021-10-12 15:03:49,817 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x037E9538>, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <listcomp>
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\legacy.py", line 354, in <genexpr>
    return (Bus(g) for k, g in groupby(
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\legacy.py", line 349, in __init__
    self.devices = [Device(d) for d in devices]
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\legacy.py", line 349, in <listcomp>
    self.devices = [Device(d) for d in devices]
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\legacy.py", line 335, in __init__
    self.configurations = [Configuration(c) for c in dev]
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\legacy.py", line 335, in <listcomp>
    self.configurations = [Configuration(c) for c in dev]
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\core.py", line 1140, in __iter__
    yield Configuration(self, i)
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\core.py", line 605, in __init__
    desc = backend.get_configuration_descriptor(
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\_debug.py", line 62, in do_trace
    return f(*args, **named_args)
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\backend\libusb1.py", line 773, in get_configuration_descriptor
    _check(self.lib.libusb_get_config_descriptor(
  File "C:\Users\rc\miniconda3\envs\conda_enlighten3\lib\site-packages\usb\backend\libusb1.py", line 604, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 2] Entity not found

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jonasmalacofilhocommented, Oct 13, 2021

One issue with the legacy interface is that it always gets the configuration descriptor for all devices in the system. Which explains why the new usb.core.find() interface by itself works fine.

If you really need to stick with the legacy interface, you’ll need to figure out which specific device is causing this, either by using a debugger or by patching usb.legacy.Device.__init__ to show which device is being instantiated before the statement self.configurations = [Configuration(c) for c in dev].


P.S. os.environ['LIBUSB_DEBUG'] = "4" did not have the desired effect, probably because that statement doesn’t actually change the environment of the process at the OS level, meaning libusb only gets/checks the environment the python process was started with. That additional information could help, so try to start python with that variable already set.

0reactions
mcueecommented, Oct 13, 2021

Which driver are you using and which libusb-1.0.dll version are you using? There are known problem with libusb0.sys and libusbk driver under libusb 1.0.24 version, please use WinUSB driver instead.

What is the process to ensure that? I’m not sure exactly what you mean I know you can set a backend in the core.find() function call, or do you mean using Zadig on the specific device?

Windows driver – you handle that with Zadig.

Based on what Jonas says, if you are stuck with legacy interface, then it is better to use libusb0.sys or libusbk.sys. What you can do is to remove libusb-1.0.dll, and then use Zadig to install libusb0.sys or libusbk.sys driver for your device, not using WinUSB driver.

The legacy interface was really developed to be compatible with the older version of pyusb, which was using libusb-0.1 API and in that case it is actually better using libusb0.dll compatible drivers like libusb0.sys or libusbk.sys.

pyusb libusb0 backend (libusb-win32 libusb0.dll) – compatible with libusb0.sys or libusbk.sys pyusb libusb-1.0 backend (libusb-1.0.dll without libusbk.dll)-- only compatible with WinUSB pyusb libusb-1.0 backend (libusb-1.0.dll with libusbk.dll) – compatible with WinUSB (recommended) and libusbk.sys (2nd choice), poor support for libusb0.sys (do not use it)

BTW, Zadig will automatically install libusb0.dll/libusbk.dll when you install libusb0.sys driver or libusbk.sys driver. Zadig will not install libusb-1.0.dll for you no matter which driver you install。

Read more comments on GitHub >

github_iconTop Results From Across the Web

PyUSB error "USBError: [Errno 2] Entity not found" using ...
I am trying to establish communication with an usb device. I do have libusb1 and libusb installed in Python as well ...
Read more >
USB Composite Device [ Entity not found ] · Issue #884 - GitHub
I use libusb(python) to read/write winusb. When I use the function libusb.bulk_transfer, I will receive an error code Entity not found.
Read more >
[Libusb-devel] LIBUSB_ERROR_NOT_FOUND
Entity not found. " If you are using the Windows backend and your device is WinUSB, this error can be returned if you...
Read more >
libusb1 - PyPI
Pure-python wrapper for libusb-1.0. ... skip_on_error=True, ) if handle is None: # Device not present, or user is not allowed to access device....
Read more >
strerror.c - platform/external/libusb - Google Git
"No such device (it may have been disconnected)",. "Entity not found",. "Resource busy",. "Operation timed out",. "Overflow",. "Pipe error",.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found