Reputation: 33
I'm receiving a no backend error in pyusb despite the fact that I have LibUSB 1 installed, in the path, and loaded fine earlier in the code. My code is
import usb.core
import usb.util
import usb.backend.libusb1
import sys
class USBConnection:
def __init__(self, vendor_id, product_id):
usb.backend.libusb1.get_backend(find_library=lambda x: 'C:\Windows\System32\libusb-1.0.dll')
self.device = usb.core.find(idVendor=vendor_id, idProduct=product_id)
if self.device is None:
sys.exit('Could not find device')
else:
print 'Device detected'
self.device.set_configuration()
self.configuration = self.device.get_active_configuration()
self.description = self.configuration[(0, 0)]
self.end_point = usb.util.find_descriptor(self.description, custome_match=lambda e: usb.util.endpoint_direction
(e.bEndpointAddress) == usb.util.ENDPOINT_OUT)
assert self.end_point is not None
def write(self, data):
self.end_point.write(data)
if __name__ == '__main__':
channel = USBConnection(vendor_id='2A19', product_id='1002')
Running this code returns
Traceback (most recent call last):
File "C:/Users/me/PycharmProjects/usbfreqsweep/usbsweep.py", line 126, in <module>
channel = USBConnection(vendor_id='2A19', product_id='1002')
File "C:/Users/me/PycharmProjects/usbfreqsweep/usbsweep.py", line 110, in __init__
self.device = usb.core.find(idVendor=vendor_id, idProduct=product_id)
File "C:\Python27\lib\site-packages\usb\core.py", line 1263, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
I do in fact have the C:\windows\system32 in my path with llibusb-1.0.dll contained and the most recent version of libusb1 installed, but I still get this error. This is in spite of the fact that
usb.backend.libusb1.get_backend(find_library=lambda x: 'C:\Windows\System32\libusb-1.0.dll')
does not return an error. Even weirder, setting
backend = usb.backend.libusb1.get_backend(find_library=lambda x: 'C:\Windows\System32\libusb-1.0.dll')
and going through in the debugger returns backend with a value of None. Is there a good way to fix this? I'm using Windows 7, if that helps.
Upvotes: 3
Views: 1163
Reputation: 1
Upvotes: 0