Registry / devops / usb-devices

usb-devices

JSON →
library0.5.1pypypi✓ verified 85d ago

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.

pip install usb-devices
INSTALL
IMPORT
SIG · USB-DEVICES
U
usb-devices
devopspythonv0.5.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

USBDevice
from usb_devices import USBDevice
from usb_devices import USBDeviceInfo

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.

from usb_devices import USBDeviceInfo print("Discovering USB devices...") try: devices = USBDeviceInfo.get_all_usb_devices() if not devices: print("No USB devices found.") for usb_device in devices: print(f"Path: {usb_device.path}") print(f"Product: {usb_device.product}") print(f"Manufacturer: {usb_device.manufacturer}") print(f"Serial: {usb_device.serial_number}") print(f"VendorId: {usb_device.vendor_id}") print(f"ProductId: {usb_device.product_id}") print(f"Bus: {usb_device.bus_number}") print(f"Address: {usb_device.device_address}") print(f"Port: {usb_device.port_number}") # Example of resetting a device (requires permissions) # if "MyDevice" in str(usb_device.product): # print(f"Attempting to reset {usb_device.product}...") # usb_device.reset_device() # print("Device reset.") print("-----------------------------------") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
gotchaAccessing 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()`.
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.
affects: All versions
gotchaEarlier 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.
fix
Ensure you are using `usb-devices` version 0.4.2 or newer. If issues persist, verify system drivers and run with administrative privileges.
affects: < 0.4.2
gotchaSome 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.
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.
affects: < 0.4.1
gotchaThe `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.
fix
If device presence changes are critical, re-call `USBDeviceInfo.get_all_usb_devices()` periodically or upon a trigger to refresh the device list.
affects: All versions
Upgrade
Version history
0.5.1latest on PyPI · released May 27, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
18
OpenAI (training)
2
Amazon
1
Resources
usb-devices — pip install usb-devices · libregistry