Windows 7 上的 Pyusb 找不到任何设备

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5385281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:28:45  来源:igfitidea点击:

Pyusb on Windows 7 cannot find any devices

pythonwindowslibusbpyusblibusb-1.0

提问by Ponkadoodle

So I installed Pyusb 1.0.0-alpha-1
Under Windows, I cannot get any handles to usb devices.

所以我安装了 Pyusb 1.0.0-alpha-1
在 Windows 下,我无法获得 USB 设备的任何句柄。

>>> import usb.core
>>> print usb.core.find()
None

I do have 1 usb device plugged in(idVendor=0x04d8, idProduct=0x0042), and I tried usb.core.find(idVendor=0x04d8, idProduct=0x0042)but that failed too.

我确实插入了 1 个 USB 设备(idVendor=0x04d8,idProduct=0x0042),我尝试过,usb.core.find(idVendor=0x04d8, idProduct=0x0042)但也失败了。

Under Ubuntu, with the same versions of pyusb and python (2.6), I am able to successfully find my device with that code, and communicate with it.

在 Ubuntu 下,使用相同版本的 pyusb 和 python (2.6),我能够使用该代码成功找到我的设备,并与之通信。

So how can I get pyusb to find usb devices on Windows 7?

那么如何让 pyusb 在 Windows 7 上找到 USB 设备呢?

回答by Turbo J

Libusb requires you to install a special driver for every device you want to use it with. That usually requires you to write an .inf file containing the USB IDs of the device. Only if the driver and inf file are installed libusb will be able to "see" your device.

Libusb 要求您为要使用它的每个设备安装一个特殊的驱动程序。这通常需要您编写一个包含设备 USB ID 的 .inf 文件。只有安装了驱动程序和 inf 文件,libusb 才能“看到”您的设备。

回答by handle

See Turbo J's answer. To install the USB driver libusbfor your device I found two options:

请参阅Turbo J 的回答。要libusb为您的设备安装 USB 驱动程序,我找到了两个选项:

  • Use libusb-win32's inf-wizard.exeto create the INF file and then use install-filter-win.exeto install libusb as driver for your device.

  • Use zadig(simpler)

    • if no device is shown, Options > List All Devices
    • select libusb-win32as driver to be installed
  • 使用的libusb-win32的inf-wizard.exe创建INF文件,然后使用install-filter-win.exe安装libusb的驱动程序为您的设备。

  • 使用zadig(更简单)

    • 如果未显示设备,则选项 > 列出所有设备
    • 选择libusb-win32作为要安装的驱动程序