PyUSB is a compilation error from the beginning no module named 'usb'

Asked 2 years ago, Updated 2 years ago, 146 views

I would like to connect the USB device (sensor) to the Raspberry Pi and use PyUSB to communicate data.The programming language is Python.
Now, pyusb, libusb are already installed, but I get the following compilation errors from the beginning:

no module named 'usb'

If you check the USB device with lsusb, the vendor ID and the product ID will also appear.What are the possible causes of the error?

import usb.core
import usb.util

python python3 raspberry-pi raspbian usb

2022-09-30 13:51

1 Answers

I don't think the pyusb module has been introduced.

pipe install pyusb
By the way, in my environment, it was as follows.

 C:\Users>python
Python 3.7.7 (tags/v3.7.7: d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>import usb.core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'usb' ★ No module found
>>quit()

Introducing the C:\Users > pip install pyusb module
Collecting pyusb
  Downloading pyusb-1.1.1-py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 4.1 MB/s
Installing collected packages:pyusb
Successfully installed pyusb-1.1.1

C:\Users > python
Python 3.7.7 (tags/v3.7.7: d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>import usb.core★Yes, complete
>>


2022-09-30 13:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.