Search code examples
pythonlibusbpyusbescposescp

libusb, pyusb and python-escpos on a windows machine


I am trying to work with Epson POS TM-82 printer on windows 7 (64 bit). I have installed the printer's driver. I have python 2.7.15 (64 bit) installed. To work with python I am using this package, python-escpos.

After I have installed python-escpos, and try to run as documented, I am getting an error:

from escpos.printer import Usb
Usb(0x04b8, 0x0e11)

usb.core.NoBackendError: No backend available

  1. After some more digging, I found this wiki, according to this I need to Use the most recent version of Zadig, an Automated Driver Installer GUI application for WinUSB, libusb-win32 and libusbK.

    So, I downloaded Zadig; from the drop-down menu selected TM-82, and chose WinUSB to replace the driver and installed the driver succesfully.

    After that again I ran the same python-escpos documented command from above, and got the same error:

    usb.core.NoBackendError: No backend available

  2. After some more research I found this answer on stackoverflow. So following the answer, I downloaded the libusb zip file, and copied libusb-1.0.20_2\MS64\dll\libusb-1.0.lib to my C:\Windows\System32. And finally copied libusb-1.0.20_2\MS64\static\libusb-1.0.lib to C:\Python27\libs\

    After that again I ran the same python-escpos documented command from above, and this time I got a different error:

    NotImplementedError: Operation not supported or unimplemented on this platform

What am I missing here? Could you please help me. Thank you.


Solution

  • Answering my own question here. So, it turns out, the problem was with python-escpos library. I had to remove the following from the printer.py (python module of that library):

    try:
        check_driver = self.device.is_kernel_driver_active(0)
    except NotImplementedError:
        pass
    if check_driver is None or check_driver:
        try:
            self.device.detach_kernel_driver(0)
        except usb.core.USBError as e:
            if check_driver is not None:
                print("Could not detatch kernel driver: {0}".format(str(e)))
    

    The details can be found on my blog on Medium.