如何在下面提到的程序中删除此错误?我得到的错误是
ImportError: No module named usb.core
我的代码是:
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')
答案 0 :(得分:1)
操作系统是Windows 8 64位[...] ValueError:没有可用的后端
请允许我翻译:您忘了安装正确的USB驱动程序。
USB设备需要驱动程序才能在Windows中运行。查看PyUSB website了解详细信息,并使用Zadig为您生成并安装驱动程序(例如LibUSB-Win32)。该程序负责Windows 8希望为您的驱动程序inf文件查看的证书。
顺便说一句:您应该用于USB开发的VID是0x4242
。
答案 1 :(得分:0)
对于错误:
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
下载并安装libusb-win32-devel-filter-1.2.6.0.exe。 它应该可以工作。