Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageWriter can't be instanciated #138

Open
arthuRHD opened this issue Dec 24, 2021 · 2 comments
Open

ImageWriter can't be instanciated #138

arthuRHD opened this issue Dec 24, 2021 · 2 comments
Labels
documentation things that need to be documented better

Comments

@arthuRHD
Copy link

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
Copy link
Author

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.

@WhyNotHugo
Copy link
Owner

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

See https://python-barcode.readthedocs.io/en/stable/getting-started.html#installation

PIL is not required if you're only generating SVG barcodes. I guess the error could be improved and point to the docs, so I'll keep this open as a reminder to improve the docs.

@WhyNotHugo WhyNotHugo added the documentation things that need to be documented better label May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation things that need to be documented better
Projects
None yet
Development

No branches or pull requests

2 participants