-1

我的代码是获取有关插入 USB 端口的设备的所有详细信息。但是,当我运行该程序时,我收到以下错误:

ImportError: No module named backend.libusb10

有人可以解释一下吗?我检查了我的站点包文件夹并且我有后端。提前致谢 :)

这是我的代码

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
4

1 回答 1

1

也许是因为你在 Windows 上工作。尝试切换到 ubuntu。在我的机器上尝试了你的代码,就像一个魅力。

脚步:

  1. 从http://sourceforge.net/projects/pyusb/下载 pyusb-1.0.0a3.zip(或任何版本)
  2. 解压 zip 文件,从终端进入该文件夹并输入“python setup.py install”
  3. 继续你正在做的事情。
于 2013-05-21T07:19:40.303 回答