简体   繁体   中英

No module named usb.core

How can I remove this error in the below mentioned program? The error iI'm getting is

ImportError: No module named usb.core

and my code is:

import usb.core
import usb.util

# find our device
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)

# was it found?
if dev is None:
    raise ValueError('Device not found')

# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()

# get an endpoint instance
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]

ep = usb.util.find_descriptor(
    intf,
    # match the first OUT endpoint
    custom_match = \
    lambda e: \
        usb.util.endpoint_direction(e.bEndpointAddress) == \
        usb.util.ENDPOINT_OUT)

assert ep is not None

# write the data
ep.write('test')

OS is windows 8 64-bit [...] ValueError: No backend available

Allow me to translate: You forgot to install the correct USB driver.

USB devices need a driver to work in Windows. Look at PyUSB website for details, and use Zadig to generate and install the driver (eg LibUSB-Win32) for you. This program takes care of the certificate that Windows 8 wants to see for your drivers inf file.

Btw: The VID you should use for USB development is 0x4242 .

For error:

C:\Users\RAHUL\Desktop\python progrms\USBsample.py, line 5, in <module>
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001) File "C:\Python27\lib\site-
packages\usb\core.py", line 864, in find raise ValueError('No backend available')
ValueError: No backend available

Download and install libusb-win32-devel-filter-1.2.6.0.exe . It should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM