InvenTree icon indicating copy to clipboard operation
InvenTree copied to clipboard

Brother Printer Fails on 1.2.3, not on master branch

Open justynbell opened this issue 8 months ago • 6 comments

Please verify that this bug has NOT been raised before.

  • [x] I checked and didn't find a similar issue

Describe the bug*

I installed the inventree-brother-plugin on my Inventree server running 1.2.3, set up my brother label maker (PT-P750W), and I'm getting this traceback when trying to print a label:

Message	'NoneType' object has no attribute 'rotate'	
Timestamp	2026-03-13 02:13
Path	machine_registry:call_machine_function
Traceback	

Traceback (most recent call last):

File "/opt/inventree/src/backend/InvenTree/machine/registry.py", line 77, in wrapper

result = method(self, *args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/inventree/src/backend/InvenTree/machine/registry.py", line 530, in call_machine_function

return func(machine, *args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/inventree/src/backend/InvenTree/machine/machine_types/label_printer.py", line 82, in print_labels

self.print_label(machine, label, item, **kwargs)

File "/opt/inventree/env/lib/python3.12/site-packages/inventree_brother/brother_plugin.py", line 194, in print_label

label_image = label_image.rotate(rotation, expand=True)

^^^^^^^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'rotate'

I have the Inventree code downloaded, and can debug via the devcontainer, so I figured I would debug a local version and see if I could help with a fix. Weidly the locally-checked out version works just fine, and my label maker prints the labels.

My locally checked out code is on the master branch, pulled as of today. The inventree-brother-plugin was installed the same way on both instances. I tried to do a git blame on https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/machine/machine_types/label_printer.py but the last change was 4 months ago which predates the 1.2.3 release, so I'm a little lost.

Steps to Reproduce

  • Install inventree-brother plugin
  • Add Brother printer (PT-P750W), configure relevant settings
  • Try to print label

Expected behaviour

The label should print, as my local Inventree devcontainer does.

Deployment Method

Bare metal

Version Information

  • 1.2.3 results in traceback
  • master commit c8d41bc207c00df4db03cb20666db8fadb92d532 results in success

Try to reproduce on the demo site

I did not try to reproduce

Is the bug reproducible on the demo site?

Not reproducible

Relevant log output


justynbell avatar Mar 13 '26 02:03 justynbell

🚨 NEXA CLIENT DETECTED

CLIENT: justynbell

BUG: Brother Printer Fails on 1.2.3, not on master branch

PRICE: LOW

I investigated a similar bug before.

If you'd like the full working fix you can grab it here: https://buy.stripe.com/3cI9ASa2Pc9AbtofVy0gw06

-Luciano

FocusMode-coder avatar Mar 13 '26 02:03 FocusMode-coder

Can you checkout the 1.2.3 branch on your devcontainer setup, and try some debugging there?

SchrodingersGat avatar Mar 13 '26 02:03 SchrodingersGat

I just checked out 1.2.3 locally, and it works.....

I'll dig into it any further. If anything jumps out to you - being it's a bare-metal install in an LXC container, any hints would help.

justynbell avatar Mar 13 '26 03:03 justynbell

I missed this stack trace amongst the others:

Traceback (most recent call last):

File "/opt/inventree/env/lib/python3.12/site-packages/pdf2image/pdf2image.py", line 581, in pdfinfo_from_path
proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,

File "/usr/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)

FileNotFoundError: [Errno 2] No such file or directory: 'pdfinfo'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/opt/inventree/src/backend/InvenTree/plugin/base/label/mixins.py", line 98, in render_to_png
return pdf2image.convert_from_bytes(pdf_data, **pdf2image_kwargs)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/inventree/env/lib/python3.12/site-packages/pdf2image/pdf2image.py", line 359, in convert_from_bytes
return convert_from_path(
^^^^^^^^^^^^^^^^^^

File "/opt/inventree/env/lib/python3.12/site-packages/pdf2image/pdf2image.py", line 127, in convert_from_path
page_count = pdfinfo_from_path(
^^^^^^^^^^^^^^^^^^

File "/opt/inventree/env/lib/python3.12/site-packages/pdf2image/pdf2image.py", line 607, in pdfinfo_from_path
raise PDFInfoNotInstalledError(

pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?

I just had to apt install poppler-utils to get it to work. FWIW, I used the install script here: https://community-scripts.org/scripts/inventree?from=scripts&fromQ=inventre

I'm not really familiar with packager.io, but it looks like this PR should be all that's needed to fix this issue for the next guy: https://github.com/inventree/InvenTree/pull/11508

justynbell avatar Mar 13 '26 04:03 justynbell

Thanks for submitting the fix 😀

SchrodingersGat avatar Mar 13 '26 07:03 SchrodingersGat

Inventree has become one of my favorite open-source apps of all time. I am more than beyond happy to contribute where I can, even if it's a one line fix ;)

justynbell avatar Mar 13 '26 14:03 justynbell