PyUSB 1.0: NotImplementedError: Operation not supported or unimplemented on this platform
Asked Answered
H

3

9

I just began to use pyusb, and basically I'm playing with the sample code here.

I'm using Windows7 64 bit, and downloaded the zip version from https://walac.github.io/pyusb/. Backend is libusb-1.0.19 that is downloaded the windows binary from http://libusb.info/.

All of my code is:

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()

At the ending line, I got

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

I have several USB devices installed, but only see this issue when I try to set_configuration for my USB flash drive...

Is this because I can't use pyusb to access the flash drive? Or there's anything I missed...

Hoot answered 12/8, 2015 at 8:49 Comment(0)
C
3

This also happened me and the problem was that the device was used by other software or driver.

Catastrophism answered 18/2, 2016 at 8:0 Comment(0)
I
3

This issue is about having the right driver on W7/64-bits. I tried to connect and use a Microchip self-programmed card. Unfortunately, the driver provided by Microchip is not compliant with the libusb library and I've go the same error.

Read: How to use libusb on Windows

Then: - the ZADIG install is executed with the Microchip card connected - then from the ZADIG popup "List all devices" allows me to detect and choose my device "CDC RS-232 Emulation Demo" ID = 04d8:000a - then multiple drivers are possible: I installed WINUSB (microsoft)

Now the first stage of device enumeration is working fine.

Intolerance answered 23/7, 2016 at 9:49 Comment(1)
this solution does not work for ESD CAN-USB/2 devices.Buddybuderus
E
0

None of the other explanations solved the issue for me. My solution was to let go of certain driver related function calls like is_kernel_driver_active. Explanation found at the very bottom of pyusb-users:

...in Windows, libusb needs a driver attached, so makes no sense a function to detach the driver

Elenor answered 28/10, 2022 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.