没有名为usb.core的模块
问题描述:
如何在下面提到的程序中删除此错误? iI'm得到的错误是没有名为usb.core的模块
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')
你在什么操作系统下运行?一般来说,你安装了PyUSB吗? – 2014-10-05 14:39:09
检查此SO问题:[链接](http://*.com/questions/24790690/importerror-no-module-named-usb-core-working-in-terminal-not-in-eclipse) – Joe 2014-10-05 14:40:11
操作系统是Windows 8 64位,是的,我已经安装,但即时得到错误: 回溯(最近呼叫最后): 文件“C:\用户\ RAHUL \桌面\ python程序\ USBsample.py”,第5行,在 dev = usb.core.find(idVendor = 0xfffe,idProduct = 0x0001) 文件“C:\ Python27 \ lib \ site-packages \ usb \ core.py”,第864行,找到 raise ValueError('No backend可用') ValueError:没有后端可用 –
2014-10-05 15:04:18