Я использую библиотеку python escposprinter для печати своих данных в термопринтере. Это зависит от пируса. библиотека отлично работает в Linux. Хотя в Windows 7 я получаю некоторые проблемы. Вот вывод, который я получаю.Pyusb в Windows 7 - NotImplemented Error: is_kernal_driver_active
File "main.py", line 1, in <module>
from app import app
File "D:\freeth-in-erp-60ab8eb96fad\app\__init__.py", line 94, in <module>
from .api_routes import *
File "D:\freeth-in-erp-60ab8eb96fad\app\api_routes.py", line 44, in <module>
from .printer import pos
File "D:\freeth-in-erp-60ab8eb96fad\app\printer\pos.py", line 14, in <module>
Epson = printer.Usb(idVendor=0x0416,idProduct=0x5011)
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\escposprinter\print
er.py", line 37, in __init__
self.open()
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\escposprinter\print
er.py", line 46, in open
if self.device.is_kernel_driver_active(0):
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\usb\core.py", line
1064, in is_kernel_driver_active
interface)
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\usb\backend\__init_
_.py", line 365, in is_kernel_driver_active
_not_implemented(self.is_kernel_driver_active)
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\usb\backend\__init_
_.py", line 81, in _not_implemented
raise NotImplementedError(func.__name__)
NotImplementedError: is_kernel_driver_active
я скачать libusb-1,20 от libusb.info и скопировать файл libusb-1.0.dll из Mingw32 и вставить в "C: \ Windows \ System32". Я получаю следующий результат.
from app import app
File "D:\freeth-in-erp-60ab8eb96fad\app\__init__.py", line 94, in <module>
from .api_routes import *
File "D:\freeth-in-erp-60ab8eb96fad\app\api_routes.py", line 44, in <module>
from .printer import pos
File "D:\freeth-in-erp-60ab8eb96fad\app\printer\pos.py", line 14, in <module>
Epson = printer.Usb(idVendor=0x0416,idProduct=0x5011)
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\escposprinter\print
er.py", line 37, in __init__
self.open()
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\escposprinter\print
er.py", line 46, in open
if self.device.is_kernel_driver_active(0):
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\usb\core.py", line
1064, in is_kernel_driver_active
interface)
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\usb\backend\libusb1
.py", line 898, in is_kernel_driver_active
intf)))
File "D:\freeth-in-erp-60ab8eb96fad\venv\lib\site-packages\usb\backend\libusb1
.py", line 593, in _check
raise NotImplementedError(_strerror(ret))
NotImplementedError: Operation not supported or unimplemented on this platform
мой код `
from escposprinter import *
from tabulate import tabulate
Epson = printer.Usb(0x0416,0x5011)
из библиотеки escposprinter
class Usb(Escpos):
""" Define USB printer """
def __init__(self, idVendor, idProduct, interface=0, in_ep=0x82, out_ep=0x01):
"""
@param idVendor : Vendor ID
@param idProduct : Product ID
@param interface : USB device interface
@param in_ep : Input end point
@param out_ep : Output end point
"""
self.idVendor = idVendor
self.idProduct = idProduct
self.interface = interface
self.in_ep = in_ep
self.out_ep = out_ep
self.open()
def open(self):
""" Search device on USB tree and set is as escpos device """
self.device = usb.core.find(idVendor=self.idVendor, idProduct=self.idProduct)
if self.device is None:
print ("Cable isn't plugged in")
if self.device.is_kernel_driver_active(0):
try:
self.device.detach_kernel_driver(0)
except usb.core.USBError as e:
print ("Could not detatch kernel driver: %s" % str(e))
помочь мне с предложением `
Даже не погуглил, не так ли? – linusg
@linusg Нет Я искал последние 7 дней –