{"id":7843,"library":"usb-devices","title":"USB Devices","description":"usb-devices is a Python library providing tools for mapping, describing, and resetting USB devices connected to the system. It offers a cross-platform API to enumerate devices and retrieve detailed information such as product, manufacturer, and serial numbers, and provides functionality to reset individual devices. The library is actively maintained, with version 0.4.5 being the latest, and sees frequent minor releases addressing compatibility and stability.","status":"active","version":"0.4.5","language":"python","source_language":"en","source_url":"https://github.com/bluetooth-devices/usb-devices","tags":["usb","device","hardware","discovery","enumeration"],"install":[{"cmd":"pip install usb-devices","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"wrong":"from usb_devices import USBDeviceInfo","symbol":"USBDevice","correct":"from usb_devices import USBDevice"}],"quickstart":{"code":"from usb_devices import USBDeviceInfo\n\nprint(\"Discovering USB devices...\")\n\ntry:\n    devices = USBDeviceInfo.get_all_usb_devices()\n    if not devices:\n        print(\"No USB devices found.\")\n    for usb_device in devices:\n        print(f\"Path: {usb_device.path}\")\n        print(f\"Product: {usb_device.product}\")\n        print(f\"Manufacturer: {usb_device.manufacturer}\")\n        print(f\"Serial: {usb_device.serial_number}\")\n        print(f\"VendorId: {usb_device.vendor_id}\")\n        print(f\"ProductId: {usb_device.product_id}\")\n        print(f\"Bus: {usb_device.bus_number}\")\n        print(f\"Address: {usb_device.device_address}\")\n        print(f\"Port: {usb_device.port_number}\")\n        # Example of resetting a device (requires permissions)\n        # if \"MyDevice\" in str(usb_device.product):\n        #     print(f\"Attempting to reset {usb_device.product}...\")\n        #     usb_device.reset_device()\n        #     print(\"Device reset.\")\n        print(\"-----------------------------------\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to discover and list all connected USB devices using `USBDeviceInfo.get_all_usb_devices()`. It prints key details for each device. Note that features like `reset_device()` typically require elevated permissions and are commented out for safe execution."},"warnings":[{"fix":"On Linux, configure udev rules (e.g., `sudo usermod -a -G dialout $USER`, then log out/in) or run the script with `sudo`. On Windows, ensure the script is run as Administrator.","message":"Accessing USB devices often requires elevated permissions (e.g., root/administrator on Linux/Windows, or specific udev rules on Linux). Failure to do so will result in `Permission denied` errors, especially when attempting operations like `reset_device()`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using `usb-devices` version 0.4.2 or newer. If issues persist, verify system drivers and run with administrative privileges.","message":"Earlier versions (prior to v0.4.2) had known issues importing and running correctly on Windows. While fixed in v0.4.2+, specific Windows configurations or device drivers might still cause unexpected behavior or prevent device detection.","severity":"gotcha","affected_versions":"< 0.4.2"},{"fix":"Upgrade to `usb-devices` version 0.4.1 or newer. Always check for `None` when accessing `usb_device.manufacturer` or `usb_device.product` for robustness.","message":"Some USB devices may not provide complete `manufacturer` or `product` information. In such cases, these attributes on the `USBDevice` object will be `None`. Prior to v0.4.1, this could sometimes lead to errors if not explicitly handled.","severity":"gotcha","affected_versions":"< 0.4.1"},{"fix":"If device presence changes are critical, re-call `USBDeviceInfo.get_all_usb_devices()` periodically or upon a trigger to refresh the device list.","message":"The `get_all_usb_devices()` method provides a snapshot of currently connected devices. It does not automatically update when devices are hot-plugged (connected or disconnected). To detect changes, you must call the method again.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.4.5':58 'activ':54 'address':67 'api':29 'compat':68 'connect':19 'cross':27 'cross-platform':26 'describ':14 'detail':35 'devic':2,5,18,32,50,72 'discoveri':74 'enumer':31,75 'frequent':64 'function':46 'hardwar':73 'individu':49 'inform':36 'latest':61 'librari':9,52 'maintain':55 'manufactur':40 'map':13 'minor':65 'number':43 'offer':24 'platform':28 'product':39 'provid':10,45 'python':8 'releas':66 'reset':16,48 'retriev':34 'see':63 'serial':42 'stabil':70 'system':22 'tool':11 'usb':1,4,17,71 'usb-devic':3 'version':57","created_at":"2026-04-16T14:15:47.055097+00:00","updated_at":"2026-04-16T14:15:47.055097+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.5.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/bluetooth-devices/usb-devices","docs":"https://usb-devices.readthedocs.io","changelog":"https://github.com/bluetooth-devices/usb-devices/blob/main/CHANGELOG.md","pypi":"https://pypi.org/project/usb-devices/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}