,所以我一直在遵循这些文档,以便可以通过Python在热式打印机上打印。
我正在运行Ubuntu,并安装了PYUSB模块。打印机是rongta rp58,它的IDVENDOR和IDPRODUCT是通过LSUSB命令(0FE6:811E)找到的。
就像说明中一样,我输入:
from escpos.printer import Usb
p = Usb(0x0fe6, 0x811e)
但是出现错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/testerdell/.local/lib/python2.7/site-packages/escpos/printer.py", line 51, in __init__
self.open()
File "/home/testerdell/.local/lib/python2.7/site-packages/escpos/printer.py", line 62, in open
check_driver = self.device.is_kernel_driver_active(0)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/core.py", line 1061, in is_kernel_driver_active
self._ctx.managed_open()
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/core.py", line 120, in managed_open
self.handle = self.backend.open_device(self.dev)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 786, in open_device
return _DeviceHandle(dev)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 643, in __init__
_check(_lib.libusb_open(self.devid, byref(self.handle)))
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
在建议创建授予访问权限的规则的文档中,但对我不起作用。
sudo nano /etc/udev/rules.d/99-escpos.rules
是我用来编辑文件的命令,这就是内部
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fe6", ATTRS{idProduct}=="811e", MODE="0664", GROUP="dialout"
更改该文件中的任何内容后,我运行此代码:
sudo service udev restart
我不确定如何使USB访问Python。当使用
的直接root访问时sudo su root
系统说" Importerror:no模块nate Escpos.printer"。我不想每次输入root访问密码。
我的UDEV规则,组,模式,用户权限是否有问题?
任何帮助将非常感谢!预先感谢:)
在UDEV规则中将模式从664更改为666,它将起作用。