{"id":4080,"library":"libusb-package","title":"Libusb Python Package (Installer)","description":"libusb-package is a Python library that functions primarily as an installation vehicle for the libusb shared C libraries, making it easier to install tools and applications that require libusb, such as pyusb. It bundles the necessary libusb binaries for various platforms and architectures, simplifying deployment by avoiding manual libusb installation. The package is actively maintained, with version 1.0.26.3 being the latest, and receives updates to support new Python versions and upstream libusb releases.","status":"active","version":"1.0.26.3","language":"en","source_language":"en","source_url":"https://github.com/pyocd/libusb-package","tags":["usb","hardware","drivers","cross-platform","pyusb","libusb"],"install":[{"cmd":"pip install libusb-package","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"libusb-package is primarily designed to provide a backend for pyusb, allowing it to find and utilize the bundled libusb shared library.","package":"pyusb","optional":true},{"reason":"Required for building libusb from source on Linux and macOS if a pre-built wheel is not available.","package":"autoconf, automake, libtool, m4","optional":true},{"reason":"Required for building libusb from source on Windows if a pre-built wheel is not available.","package":"Visual Studio 2019 (or newer)","optional":true}],"imports":[{"symbol":"libusb_package","correct":"import libusb_package"}],"quickstart":{"code":"import libusb_package\nimport usb.core\nimport usb.backend.libusb1\n\n# Get a PyUSB backend using the bundled libusb library\nbackend = usb.backend.libusb1.get_backend(find_library=libusb_package.find_library)\n\n# Use the backend to find USB devices (example with pyusb)\ndev = usb.core.find(idVendor=0xffff, idProduct=0xffff, backend=backend)\n\nif dev is None:\n    print(\"Device not found. Make sure it's connected and drivers are installed (especially on Windows).\")\nelse:\n    print(f\"Found device: {dev.product} (Bus {dev.bus}, Address {dev.address})\")\n    # Further operations with 'dev' using pyusb\n","lang":"python","description":"This quickstart demonstrates how to import `libusb_package` and use its `find_library` function to provide a backend for `pyusb`, allowing `pyusb` to utilize the libusb shared library bundled within `libusb-package`. It then attempts to find a generic USB device (replace with your actual Vendor/Product ID)."},"warnings":[{"fix":"Upgrade your Python environment to 3.7 or newer.","message":"Python 3.6 support was officially dropped starting with `libusb-package` v1.0.26.1.","severity":"breaking","affected_versions":">=1.0.26.1"},{"fix":"Install the appropriate USB driver (e.g., WinUSB, libusbK) for your device using a tool like Zadig after installing `libusb-package`.","message":"On Windows, `libusb-package` installs the `libusb` DLL, but it *does not* install the necessary device drivers (e.g., WinUSB or libusbK). Users must manually install these drivers for their specific USB devices, often using tools like Zadig. Without the correct driver, your Python application will not be able to access the USB device.","severity":"gotcha","affected_versions":"All versions on Windows"},{"fix":"Ensure all necessary build dependencies (e.g., autoconf, automake, Visual Studio) are installed before attempting a source installation, or ensure a pre-built wheel is available for your platform and Python version.","message":"If `libusb-package` is installed from a source distribution and the underlying C `libusb` build fails (e.g., due to missing build tools), the Python package installation will still succeed but will result in an 'empty' `libusb-package` that does not contain the shared library. In such cases, `libusb_package.get_library_path()` will return `None`, and `find_library()` will fall back to `ctypes.util.find_library()` to search for a system-wide `libusb` installation.","severity":"gotcha","affected_versions":"All versions, when installing from source without pre-built wheels"},{"fix":"Upgrade `libusb-package` to version 1.0.24.1 or newer, or ensure you are running Python 3.9+.","message":"Versions of `libusb-package` prior to 1.0.24.1 had an issue with the `functools.lru_cache()` decorator that prevented it from working correctly on Python versions earlier than 3.9.","severity":"gotcha","affected_versions":"<1.0.24.1"},{"fix":"No user-facing fix is typically required unless custom code was deeply coupled with `libusb_package`'s internal resource handling. Ensure you are on the latest version for internal compatibility.","message":"The internal usage of `importlib.resources` API was replaced in v1.0.26.2 due to deprecation. While this was an internal change, direct interaction with `libusb_package`'s resource loading mechanisms (if any existed in user code) might require review.","severity":"deprecated","affected_versions":"<1.0.26.2"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}