【问题标题】:escpos erro 'usb_detach_kernel_driver_np' not foundescpos 错误 'usb_detach_kernel_driver_np' 未找到
【发布时间】:2019-01-24 15:51:30
【问题描述】:

我尝试用热敏打印机打印一张票。我使用模块escpos

但是当我在 Windows 中运行脚本时,它会向我发送以下错误

Traceback (most recent call last):
      File "C:\Users\Angel\Desktop\Escritorio\impreimer.py", line 5, in <module>
        Epson = printer.Usb(0x1a86,0x7584,1)
      File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\escpos\printer.py", line 51, in __init__
        self.open()
      File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\escpos\printer.py", line 68, in open
        self.device.detach_kernel_driver(0)
      File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\usb\core.py", line 1077, in detach_kernel_driver
        interface)
      File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\usb\backend\libusb0.py", line 606, in detach_kernel_driver
        _check(_lib.usb_detach_kernel_driver_np(dev_handle, intf))
      File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 361, in __getattr__
        func = self.__getitem__(name)
      File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 366, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: function 'usb_detach_kernel_driver_np' not found
    [Finished in 0.5s with exit code 1]

这是我的代码:

import sys
from escpos import *

pr = printer.Usb(0x1a86,0x7584)

我该如何解决这个问题?

【问题讨论】:

    标签: python python-3.x escpos


    【解决方案1】:

    试试这个。

    pr = 打印机.Usb(0x1a86,0x7584, interface=0, in_ep=0x82, out_ep=0x02)

    如果您使用的是 Windows,则需要使用 zadig 或 LibusbK 等程序并安装过滤器。

    https://zadig.akeo.ie/

    http://libusbk.sourceforge.net/UsbK3/index.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-08
      • 2012-05-26
      • 2018-11-13
      • 2023-03-11
      • 2018-12-04
      • 2017-05-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多