PyUSB 1.0:NotImplementedError:此平台不支持或未实现操作

问题描述 投票:0回答:4

我刚刚开始使用 pyusb,基本上我正在使用示例代码here

我使用的是Windows7 64位,并从https://walac.github.io/pyusb/下载了zip版本。后端是 libusb-1.0.19,从 http://libusb.info/.

下载 Windows 二进制文件

我所有的代码是:

dev = usb.core.find(idVendor=3544, idProduct=9736)
if dev is None:
    sys.stdout.write("No device found")
    return;
print "deviceClass = " + str(dev.bDeviceClass);
for cfg in dev:
    sys.stdout.write("configuration: " + str(cfg.bConfigurationValue) + '\n')
    for intf in cfg:
        sys.stdout.write('\tInterface: ' + \
                             str(intf.bInterfaceNumber) + \
                             ',' + \
                             str(intf.bAlternateSetting) + \
                             '\n')
        for ep in intf:
            sys.stdout.write('\t\tEndpoint: ' + \
                                  str(ep.bEndpointAddress) + \
                                  ',' + \
                                  str(ep.bmAttributes) + \
                                  '\n')

dev.set_configuration()

在最后一行,我得到了

File "test.py", line 44, in find_mine
    dev.set_configuration()
File "c:\Python27\lib\site-packages\usb\core.py", line 842, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
File "c:\Python27\lib\site-packages\usb\core.py", line 128, in managed_set_configuration
    self.managed_open()
File "c:\Python27\lib\site-packages\usb\core.py", line 106, in managed_open
    self.handle = self.backend.open_device(self.dev)
File "c:\Python27\lib\site-packages\usb\backend\libusb1.py", line 778, in open_device
    return _DeviceHandle(dev)
File "c:\Python27\lib\site-packages\usb\backend\libusb1.py", line 640, in __init__
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
File "c:\Python27\lib\site-packages\usb\backend\libusb1.py", line 590, in _check
    raise NotImplementedError(_strerror(ret))
NotImplementedError: Operation not supported or unimplemented on this platform

我安装了多个 USB 设备,但仅当我尝试

set_configuration
我的 USB 闪存驱动器时才看到此问题...

这是因为我无法使用pyusb访问闪存驱动器吗?或者有什么我错过的...

python python-2.7 libusb pyusb libusb-1.0
4个回答
3
投票

我也遇到过这种情况,问题是该设备被其他软件或驱动程序使用。


3
投票

此问题与 W7/64 位上是否有正确的驱动程序有关。 我尝试连接并使用 Microchip 自编程卡。不幸的是,Microchip 提供的驱动程序与 libusb 库不兼容,我也遇到了同样的错误。

阅读:如何在 Windows 上使用 libusb

然后: - ZADIG 安装是在连接了 Microchip 卡的情况下执行的 - 然后从 ZADIG 弹出窗口“列出所有设备”允许我检测并选择我的设备“CDC RS-232 仿真演示”ID = 04d8:000a - 然后可以使用多个驱动程序:我安装了 WINUSB (microsoft)

现在设备枚举的第一阶段工作正常。


0
投票

其他解释都没有为我解决这个问题。我的解决方案是放弃某些与驱动程序相关的函数调用,例如

is_kernel_driver_active
。 解释位于 pyusb-users:

最底部

...在 Windows 中,libusb 需要附加驱动程序,因此没有意义 分离驱动程序的功能


0
投票

我也有同样的问题。安装 Zydig 和安装 WinUSB 对我来说很有效

https://github.com/libusb/libusb/wiki/Windows#user-content-Supported_Environments

© www.soinside.com 2019 - 2024. All rights reserved.