I have been building an complete Invoice / Cashier system for Cafés in my spare time for quite some time. It consists of an server, running the web app, an laptop to use as the real cashier system, multiple Android Phones as a way for the waiters to enter their orders and two Raspberry Pis with Brother QL-570s as Invoice Printers. One of those is set at the counter, printing the "normal invoice", the second one is located at the kitchen and got some special routing logic, so that it only recieves the items actually produced in the kitchen. However, as I was using these special kind of printers, I was bound to use the printer-ptouch drivers... and yeah, they are *kind of* buggy. Buggy in that way, that, after installing them with cups and hacking your paper media in there - they will just stop working from time to time. Without further warning. They will stop printing just somewhere in the middle of the job. I really tried all options available to me now - and was now keen on finding *other* kinds of solutions. And after two days of searching, I stumpled upon this master piece: https://github.com/pklaus/brother_ql. Mr. Philipp Klaus did actually dump the whole cups and printer server stuff and directly converted png files into the needed binary code for the printer. And not only the QL-570, but other types as well. I really recommend checking out his code and trying his way on printing - its a huge timesaver, especially on embedded devices like the Raspberry Pi :)!
Hello Nico,
didi you manage to print on a Raspberry pi with brother_ql library ? I am getting error from my printer model QL-700. That is supposed to be supported.
I added my user to the group lp and gave write permission for the group to /dev/usb/lp0
I disabled the 'Editor Lite' mode from the printer as the documentation is saying.
Any other configuration that you can think would help a lot. I am not very knowledgable of linux or raspian and I suspect I may miss some configurations, permissions somewhere....
Salut Alexandre,
yes I got it running, however, with a QL-570 and I am using the Python binding directly in a container environment as root process.
So I am a bit off from normal operations and do not have a QL-700 for testing.
I would recommend using the debug mode on brother_ql_create - and if you would be using brother_ql_print as well, i would see to go through the special readme section for that:
"If your printer has problems printing the instructions file, it may blink its LED (green or red) depending on the model. This can have many reasons, eg.:
- The selected label doesn't match (make sure --red has been passed to brother_ql_create if you're using black/red labels).
- End of paper.
- Unsupported opcode (wrong --model when using brother_ql_create?)"
And if that does not help, you could always start by getting it working on a regular Ubuntu or Debian system and then iterate from that point on. Or open an issue on https://github.com/pklaus/brother_ql
Sorry that I cannot point to anything else, but debugging without hardware is always a bit problematic and as I am not the dev, I can only point back to him.
Regards,
Nico
Hai Nico,
Iam a newbie with raspberry and python but hopefully you would have time to answer my stupid question
I have a project also to print barcode through raspberry pi, i choose brother_ql label printer and download Mr.pklaus driver
After several try and attempt,i finally can use it to print through command prompt,
Problem now i want to make the printer work automatically with supplied database for the number which will change to barcode then printed
I have made the py code to change number with python to be png image and save at home/pi folder,and then called through cmd to print image.png
There were 3 line command to print through cmd: (using pklaus driver)
export brother_ql_print=usb:// (connection)
export brother_ql_print=ql-800 (printer type)
brother_ql_print -l image.png (Image name)
My problem now,how to call are the 3 command through python idle?
I try to use subprocess, unfortunately just find out it won't work with export command .
Please help.
Thanks.
Hello Meirina,
fist of all, export is a command to provide an environmental variable to a shell (i.e. BASH). However, subprocess does not necesarily create one and with that, brother_ql_print will not have a connection or printer type to work with, as these values would be lost as soon as the last command is executed. The commands you provided cannot really work, and I think these are copy & paste errors:
export brother_ql_print=usb:// (connection)
export brother_ql_print=ql-800 (printer type)
brother_ql_print -l image.png (Image name)
are incorrect. You're setting the variable brother_ql_print to usb://, then to the printer type - and the real program brother_ql_print cannot work with that, the correct execution would be shown in the readme of pklaus library:
export BROTHER_QL_PRINTER=tcp://192.168.1.21
export BROTHER_QL_MODEL=QL-710W
brother_ql print -l 62 my_image.png
Also, you're missing the correct lable type (there is nothing after -l at your command, so it will fail there as well, third problem).
If you insist on getting it working, you can also provide the printer type and connection with command line parameters as shown in the README of pklaus, you do not need to use export. Something like:
brother_ql --printer usb:// --model ql-800 print -l 62 image.png
should work - given you've entered the correct connection, model type, matching label type as shown in the README and image filename in your folder.
As you're using Python, it would be really more sensible to actually use pklaus program not as standalone software and invoke it, but use it as a Python Library and directly command it within your python script. Much more options, easier and useful.
Please read the README of pklaus software thoroughly as he made an awesome job in explaining everything needed,
Hi nico,
Thank you for your feedback, actually my code was sent incomplete in last comment,but actually i've typed completely and it worked with cmd.
Here is the complete code with cmd:
$ export BROTHER_QL_PRINTER=usb://0x04f9:0x209b/000E8Z353266
$ export BROTHER_QL_MODEL=QL-800
$brother_ql print -l 29x90 -t 30 putar1.png
My problem is i want to call above command through python,and subprocess partly worked. I don't get the idea about using the pklaus as library and command with python. Do you have any suggestion how to do it?
My last try is change the export to environment and call the print module as below:
os.environ (since export where not work directly)
os.environ["export BROTHER_QL_PRINTER"]="usb://0x04f9:0x209b/000E8Z353266"
os.environ["export BROTHER_QL_MODEL"]="QL-800"
For the print command, I use subprocess
e = subprocess.getoutput("brother_ql print -l 29x90 -t 30 putar1.png")
print(e)
Error not happened,but because i print the command,it said something missing as below:
brother_ql.execptions.BrotherQLUnknownModel
Looks like the environment state is failed. Any suggestion?
Hello Meirina,
I already gave you two solutions for your problem.
First was to research on how to use Python Libraries and the ql_brother library.
Second one was how to invoke printing with subprocess, specifying the connection and printer within the command line and not via environmental variables (researching what an environmental variable is, when it is valid and how it ties together with subprocess etc would also give you answers to your problem.)
So, taking the easy way out, you could just combine my answer with your data, which would give you something like this:
e = subprocess.getoutput("brother_ql --printer usb://0x04f9:0x209b/000E8Z353266 --model QL-800 print -l 29x90 -t 30 putar1.png")
print(e)
If you would be curious on how to use the library from within Python, you should look up all available material - especially the Github Repository from pklaus. This means not only the documentation and readme, but also the Issues (Solved AND Unsolved!) - because sometimes, artifacts like those contain very useful and important information (infact, there *IS* an example on how to use the library from within python with your specific printer!).
In short: I saw that you asked the same question all over the net and on stackoverflow etc. The reason why your question was downvoted there, was that you did not provide enough information and did not even borther to read the documentation of subprocess, which would tell you that it - for the most part - disregards environmental variables altogether and therefore cannot work this way.
Leason learned: It is always ok to ask for help, that is the only way to learn and very important - but please do also read the documentations of the specific parts you want to use beforehand and not just blindly throw problems at people and expect people to solve them for you - showing at the same time that you did not even bother to do one simple Google search, as this will only upset people and at the same time keep you away from growing an deeper understanding on how i.e. Linux or Python works - which is important, as without that knowledge, you will make your life (in terms of programming) a lot harder than it needs to be - and your solutions more error prone.
So please "read the very fine manual(s)" in the future, as it will help you a lot 🙂
And by the way, that is the issue I mentioned:
https://github.com/pklaus/brother_ql/issues/33
Best of luck
Hai nico,
Thank you for your valuable answer and feedback
Actually i've solved the problem before your answer but keep throw into this blog as back up while i keep searching.
I've tried the whole thing about how to work between the printer and python in about 3 days and already read everything in my opinion. Stressfull maybe make me not really understand the guideline, since this is my lab project and i was the one responsible to buy the printer because i found this library from pklaus. Unfortunately use the library is not that easy since i also new with subprocess and also my team.
Since we may have different time phase, that make i/you not answer directly. And my sincere apology to you. I know how this community work and i really hectic last time. 3 days stress and end up with simple line command. But i learn a lot though #grin
Thanks again for replying me and spare your time to help me. Really appreciate.
Best wishes,
Meirina