I'am trying to take over an barcode scanner using pyusb and pyusb-keyboard-a-like.
I have a system running win7. I have installed usb drivers with libusb-win32
both filter and inf-wizard.
my code looks like this:
from keyboard_alike import reader
class BarCodeReader(reader.Reader):
pass
if __name__ == "__main__":
reader = BarCodeReader(0x0c2e, 0x0b41, 84, 6, should_reset=False)
reader.initialize()
print(reader.read().strip())
reader.disconnect()
and gives me the following error:
Traceback (most recent call last):
File "C:\Users\Alexander\Downloads\pyusb-keyboard-alike-master\pyusb-keyboard-alike-master\lindy_bar_code_scanner.py", line 14, in <module>
reader.initialize()
File "C:\Users\Alexander\Downloads\pyusb-keyboard-alike-master\pyusb-keyboard-alike-master\keyboard_alike\reader.py", line 37, in initialize
self._device = usb.core.find(idVendor=self.vendor_id, idProduct=self.product_id)
File "C:\Python27\lib\site-packages\usb\core.py", line 846, in find
raise ValueError('No backend available')
ValueError: No backend available
how can i resolve this error?
You have to provide a backend, namely a
libusb
implementation, either bylibusb-0.1
, bylibusb-1.0
or byopenusb
(as seen in the folderpyusb-<version>\usb\backend
). In your case, it islibusb-0.1
since you usedlibusb-win32
, consequently the python script must be able to findlibusb0.dll
in the libraries path. I provided a solution for this typical problem here: PyUSB ValueError: No backend available.