pyusb ValueError: No backend available bar code scanner

1.3k Views Asked by At

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?

1

There are 1 best solutions below

0
On

You have to provide a backend, namely a libusb implementation, either by libusb-0.1, by libusb-1.0 or by openusb (as seen in the folder pyusb-<version>\usb\backend). In your case, it is libusb-0.1 since you used libusb-win32, consequently the python script must be able to find libusb0.dll in the libraries path. I provided a solution for this typical problem here: PyUSB ValueError: No backend available.