Python-printer-escpos usb.core.NoBackendError:无后端可用

时间:2019-04-02 18:38:49

标签: python

我正在尝试将python连接以打印到POS打印机,并且在获取并设置正确的USB供应商ID,产品ID,接口号,输入端点ID,输出端点ID后,它始终显示此错误。这是我的代码

from escpos.connections import getUSBPrinter

printer = getUSBPrinter()(idVendor=0x0483,
                          idProduct=0x5743,
                          inputEndPoint=0x82,
                          outputEndPoint=0x01) # Create the printer object with the connection params

printer.text("Hello World")
printer.lf()

这是完整的错误

  File "C:\Users\admin\Desktop\test\testGround\test.py", line 6, in <module>
    outputEndPoint=0x01) # Create the printer object with the connection params
  File "C:\Python36\lib\site-packages\escpos\connections.py", line 87, in __init__
    self.__open()
  File "C:\Python36\lib\site-packages\escpos\connections.py", line 101, in __open
    self._device = usb.core.find(idVendor=self.idVendor, idProduct=self.idProduct)
  File "C:\Python36\lib\site-packages\usb\core.py", line 1263, in find
    raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
Exception ignored in: <bound method getUSBPrinter.<locals>.USBPrinter.__del__ of <escpos.connections.getUSBPrinter.<locals>.USBPrinter object at 0x00000000022E85C0>>
Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\escpos\connections.py", line 134, in __del__
    if self._device:
AttributeError: 'USBPrinter' object has no attribute '_device'
[Finished in 0.3s with exit code 1]
[shell_cmd: python -u "C:\Users\admin\Desktop\test\testGround\test.py"]
[dir: C:\Users\admin\Desktop\test\testGround]
[path: C:\Python36\Scripts\;C:\Python36\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\admin\AppData\Roaming\npm]```

0 个答案:

没有答案