ImageWriter can't be instanciated #138

Open
opened 2021-12-24 12:00:01 +01:00 by arthuRHD · 1 comment
arthuRHD commented 2021-12-24 12:00:01 +01:00 (Migrated from github.com)

Env:

  • python-barcode v0.13.1
  • python 3.8.10

Whenever I try to store a picture without the default SVG writer, tjis error shows up

>>> iw = ImageWriter(format="PNG")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable

After looking at the code, there is an IF statement that prevent the class declaration in barcode/writer.py at line 330.

if Image is None:
    ImageWriter = None
else:

    class ImageWriter(BaseWriter):  # type: ignore
        format: str
        mode: str
        dpi: int
        ...
Env: - python-barcode v0.13.1 - python 3.8.10 Whenever I try to store a picture without the default SVG writer, tjis error shows up ``` >>> iw = ImageWriter(format="PNG") Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'NoneType' object is not callable ``` After looking at the code, there is an IF statement that prevent the class declaration in barcode/writer.py at line 330. ``` if Image is None: ImageWriter = None else: class ImageWriter(BaseWriter): # type: ignore format: str mode: str dpi: int ... ```
arthuRHD commented 2021-12-24 13:25:15 +01:00 (Migrated from github.com)

nvm, should had checked the head of the file. Everything is fixed when I installed PIL.

It would be nice to include PIL as a package requirement.

nvm, should had checked the head of the file. Everything is fixed when I installed PIL. It would be nice to include PIL as a package requirement.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
WhyNotHugo/python-barcode#138
No description provided.