Import BrotherPrint python scrip to print on Brother Printer Label Makers

I am trying to print to a brother printer and have been able to easily do it using python, but get the following error when I try to import the brotherprint python library:

Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\Scott Jenkins.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\brotherprint.py”, line 137
cut_settings = {‘full’ : 0b00000001, ‘half’ : 0b00000010, ‘chain’: 0b00000100, ‘special’: 0b00001000}
^
SyntaxError: no viable alternative at input ‘b00000001’

The brother print library can be found at: https://test.pypi.org/project/brotherprint/0.1.3/

Any help would be greatly appreciated!

It looks like this library requires at least Python 2.6 (binary literals are from 2.6).

Ignition’s Python implementation is currently based on 2.5. You’ll have to either port that library to 2.5 yourself or find another one.

See https://stackoverflow.com/questions/1476/how-do-you-express-binary-literals-in-python

Basically, you’ll have to start with replacing all occurences of 0b000100 and alike to int("000100", 2), as the used syntax is new for Python 2.6.

You may bump into additional problems, but I guess 2.5 and 2.6 should still be rather compatible.

Thanks guys - after replacing the syntax on the binary definitions everything worked fine and I was able to send print commands to the label printer

2 Likes

Hi, I’m printing on a brother printer too, I plan to use the library you used, could you help me or give an example of how you did it? I am starting with this type of application!