Last modified: May 28, 2025 By Alexander Williams

How to Install PyUSB in Python Easily

PyUSB is a Python library for USB device communication. It simplifies USB interactions. This guide helps you install PyUSB easily.

Prerequisites

Before installing PyUSB, ensure you have Python installed. Check using:


import sys
print(sys.version)

You also need pip, Python's package manager. Verify it with:


pip --version

If you need help with pip, check our guide on installing PyInstaller for similar steps.

Install PyUSB Using pip

The easiest way to install PyUSB is via pip. Run this command:


pip install pyusb

This downloads and installs the latest PyUSB version. Wait for the process to complete.

Verify the Installation

After installation, verify PyUSB works. Run Python and try importing it:


import usb.core
print("PyUSB installed successfully!")

If no errors appear, PyUSB is ready. For troubleshooting, see the next section.

Troubleshooting Common Issues

Permission errors may occur on Linux/Mac. Fix them by adding your user to the dialout group:


sudo usermod -a -G dialout $USER

For backend issues, install libusb. On Ubuntu/Debian:


sudo apt-get install libusb-1.0-0-dev

Windows users may need to install drivers. Check our PyWin32 guide for Windows-specific tips.

Basic PyUSB Example

Here's a simple script to list connected USB devices:


import usb.core

# Find all devices
devices = usb.core.find(find_all=True)

# Print device info
for device in devices:
    print(f"Device: {device.idVendor}:{device.idProduct}")

This outputs connected USB device IDs. For more advanced use, see PyUSB documentation.

Alternative Installation Methods

If pip fails, try these methods:

1. From source: Download PyUSB source and run:


python setup.py install

2. Using conda: If you use Anaconda:


conda install -c conda-forge pyusb

For other Python libraries, see our guide on installing PySide.

Conclusion

Installing PyUSB is straightforward with pip. Verify the installation and handle permissions properly. Now you can work with USB devices in Python.

PyUSB enables powerful USB device interactions. Start with simple scripts and explore its full potential for your projects.