matmair / brother_ql-inventree

Python package for the raster language protocol of the Brother QL series label printers
GNU General Public License v3.0
27 stars 10 forks source link

AttributeError exception due to backward incompatible change in Pillow 10.0.0 #33

Closed Emily3403 closed 5 months ago

Emily3403 commented 1 year ago

This is essentially a copy of this issue of the original brother_ql repository.

If Pillow >= 10.0.0 is installed, the program fails with the following stacktrace:

Traceback (most recent call last):
  File "/home/emily/.local/bin/brother_ql", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emily/.local/lib/python3.11/site-packages/brother_ql/cli.py", line 146, in print_cmd
    instructions = convert(qlr=qlr, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emily/.local/lib/python3.11/site-packages/brother_ql/conversion.py", line 113, in convert
    im = im.resize((dots_printable[0], hsize), Image.ANTIALIAS)
                                               ^^^^^^^^^^^^^^^
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

As recommended in this Stackoverflow post, the fix consists of renaming Image.ANTIALIAS to Image.LANCZOS.

This Pull Request already makes all the necessary changes for the original repo.

Currently, a fix is to force the old Pillow version with pip install --force-reinstall -v "Pillow==9.5.0", however I'd prefer if I was able to directly install and use the software.

Thanks and cheers in advance 😊

matmair commented 5 months ago

Hi @Emily3403 I had notitifications of for this repo - no idea why - and did not see this till now. This was addressed in https://github.com/matmair/brother_ql-inventree/pull/37 so updating the package should solve the issues. Please let me know if this works for you now.

Emily3403 commented 5 months ago

Seams to work fine, thanks!