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

TypeError running # Example with PNG in usage guide #12

Closed
DannyDannyDanny opened this issue Aug 3, 2018 · 9 comments
Closed

TypeError running # Example with PNG in usage guide #12

DannyDannyDanny opened this issue Aug 3, 2018 · 9 comments

Comments

@DannyDannyDanny
Copy link

I'm running Python 3.5.5. A subsection of the usage guide:

import barcode
from barcode.writer import ImageWriter
EAN = barcode.get_barcode_class('code128')
ean = EAN(u'5901234123457', writer=ImageWriter())

...gives me the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-67-21778fac1b87> in <module>()
----> 1 ean = EAN(u'5901234123457', writer=ImageWriter())

TypeError: 'NoneType' object is not callable

Am I doing something wrong?

@JWarmenhoven
Copy link

It runs when using writer=ImageWriter, but then an SVG image is created. Not a PNG.

@code807
Copy link

code807 commented Aug 19, 2018

Ok so I finally figured out what this is. ImageWriter tries to import Image, which used to come from PIL, (Python Image Library) which is no longer supported or included with Python. This issue can be remedied by installing Pillow, which is a working fork of PIL.

Side note: Pretty sure this makes Pillow a dependency for python-barcode.

@WhyNotHugo
Copy link
Owner

WhyNotHugo commented Aug 19, 2018 via email

@code807
Copy link

code807 commented Aug 19, 2018

I see it now. Maybe PIL should be specified or linked as pillow? PIL is no longer entirely accurate, since only a fork works.

@WhyNotHugo
Copy link
Owner

Pillow is listed as an optional dependency, not PIL.
Some docs still have outdated PIL references, so I've updated these.

@wellmonwu
Copy link

pls ,update PIL to Pillow for python3, and add the Pillow dependency to be must when pip install python-barcode

@WhyNotHugo
Copy link
Owner

@wellmonwu Please see previous comments. PIL has never been listed as a dependency; only pillow. Also, python2 has never supported, only python3.

Finally, pillow is only required if you're exporting image files (eg: not svg), so it will always be listed as an optional dependency, not a"must".

@DannyDannyDanny
Copy link
Author

DannyDannyDanny commented Jul 22, 2019

@WhyNotHugo Perhaps this could explicitly be stated in the error.

@wellmonwu Please see previous comments. PIL has never been listed as a dependency; only pillow. Also, python2 has never supported, only python3.

Finally, pillow is only required if you're exporting image files (eg: not svg), so it will always be listed as an optional dependency, not a"must".

@wellmonwu
Copy link

wellmonwu commented Jul 22, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants