Dourave
Dourave

Reputation: 51

"ModuleNotFoundError: No module named 'usb'" in Python

To read a file from a USB device, I used the 'usb' package, but I'm not able to import that package.

But in my Python and virtual environment, there is the 'usb' module installed, and it is present there, but still I'm getting this error:

Enter image description here

I need to read the file inside my USB using Python (the file located inside the USB) and I don't understand about this error.

These are the installed packages:

cd ~/PycharmProjects/pythonProject
pip freeze

Output:

asciitable==0.8.0
monitoring==0.9.12
psutil==5.9.0
pyudev==0.23.2
pyusb==1.2.1
six==1.16.0
usb==0.0.83.dev0

I'm referred to Programming with PyUSB 1.0 to access the USB device.

How can I read a file that is located inside the USB storage using Python?

Upvotes: 2

Views: 21346

Answers (2)

Peter
Peter

Reputation: 49

  1. First make sure that you have installed this package under the right virtual environment. If not, please install in that environment
  2. Sometimes, it happens like this, so just restart the PyCharm instance and rerun the code

Upvotes: 1

Robin
Robin

Reputation: 133

Make sure to install pyusb with pip install pyusb and not usb.

Then you should be able to import usb and use it as expected.

Upvotes: 6

Related Questions