Everything installed fine to get the Raspberry Pi version of the brother printer driver. I used https://support.brother.com/g/b/downloadtop.aspx?c=us&lang=en&prod=lpql800eus and I used https://pypi.org/project/brother-ql/
Using the traceback, how can I understand what value I should use for the variable "printer"? I think that is the issue.
Here is the code:
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)
Here is the error:
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: ''
(moving comment to answer)
In your code, you are specifying the printer path as /dev/usb/lp0
but specifying the backend as pyusb
. For USB, the library expects a path like 'usb://0x04f9:0x209b' which caused the error you see. The path you have (/dev/usb/lp0) indicates a linux_kernel backend. Try updating your code accordingly.
backend = 'linux_kernel'
The brother_ql library can also guess the backend based on the path format.
You can view the module source here: