我的代码是获取有关插入USB端口的设备的所有详细信息。 但是,当我运行程序时,我收到以下错误:
ImportError: No module named backend.libusb10
有人可以解释一下吗? 我检查了我的site-packages文件夹,我有后端。 提前谢谢:)
这是我的代码
import usb.core
import usb.util
import usb
# find our device
dev = usb.core.find(find_all=True)
busses = usb.busses()
# was it found?
if dev is None:
raise ValueError('Device not found')
for bus in busses:
devices = bus.devices
for dev in devices:
try:
_name = usb.util.get_string(dev.dev, 19, 1)
except:
continue
dev.set_configuration()
cfg = dev.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
alternate_settting = usb.control.get_interface(interface_number)
print "Device name:",_name
print "Device:", dev.filename
print " idVendor:",hex(dev.idVendor)
print " idProduct:",hex(dev.idProduct)
for config in dev.configurations:
print " Configuration:", config.value
print " Total length:", config.totalLength
print " selfPowered:", config.selfPowered
print " remoteWakeup:", config.remoteWakeup
print " maxPower:", config.maxPower
print
答案 0 :(得分:1)
也许是因为你正在开发Windows。尝试切换到ubuntu。 在我的机器上试过你的代码,就像一个魅力。
步骤: