一切安装良好,以获得兄弟打印机驱动程序的 Raspberry Pi 版本。我使用 了 https://support.brother.com/g/b/downloadtop.aspx?c=us&lang=en&prod=lpql800eus,我使用了 https://pypi.org/project/brother-ql/
使用回溯,我如何理解我应该为变量“打印机”使用什么值?我认为这就是问题所在。
这是代码:
import pygame
from PIL import Image
from brother_ql.conversion import convert
from brother_ql.backends.helpers import send
from brother_ql.raster import BrotherQLRaster
#####################################################################################################
### Test QR-800 Printer
#####################################################################################################
im = Image.open('QLtest.png')
im.resize((306, 991))
backend = 'pyusb' # 'pyusb', 'linux_kernal', 'network'
model = 'QL-800' # your printer model.
# HERE IS WHERE THE PROBLEM HAPPENS
# The code said to use a value from the Windows usb driver filter of 'usb://0x04f9:0x209b'
# or if have a Raspberry Pi Zero, to use for Linux/Raspberry Pi '/dev/usb/lp0'.
# So I tried with '/dev/usb/lp0' but get error
printer = '/dev/usb/lp0'
qlr = BrotherQLRaster(model)
qlr.exception_on_warning = True
instructions = convert(
qlr=qlr,
images=[im], # Takes a list of file names or PIL objects.
label='29x90',
rotate='90', # 'Auto', '0', '90', '270'
threshold=70.0, # Black and white threshold in percent.
dither=False,
compress=False,
red=False, # Only True if using Red/Black 62 mm label tape.
dpi_600=False,
lq=False, # True for low quality.
no_cut=False
)
send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)
这是错误:
Traceback (most recent call last):
File "test_printer.py", line 36, in <module>
send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)
File "/home/pi/.local/lib/python3.5/site-packages/brother_ql/backends/helpers.py", line 57, in send
printer = BrotherQLBackend(printer_identifier)
File "/home/pi/.local/lib/python3.5/site-packages/brother_ql/backends/pyusb.py", line 79, in __init__
vendor, product = int(vendor, 16), int(product, 16)
ValueError: invalid literal for int() with base 16: ''