15 May
2008

I was using the zope server to generate barcode images using PIL, and
found one of my PIL methods was throwing a python error when used in Zope (from an external method), but not otherwise.

The error is a follows:


Error Type: AttributeError
Error Value: 'module' object has no attribute '_save'

The reason for this is that JpegImagePlugin.py
called a module called ImageFile from the PIL library, but Zope also defined a (different) module called ImageFile. Argh!!

Fixing this (for me) involved going into JpegImagePlugin.py
and replacing the line "import ImageFile"
with "from PIL import ImageFile".

A quick fix that took a very long time to track down. This solution is provided here to help the next hapless soul who tries Googling for this error like I did. Now there is at least one solution out here, instead of just queries.

You can see the fixed method in action at

http://www.dudek.org/Barcodes/barcode_ean13.jpg

or use
http://www.dudek.org/Barcodes/barcode_ean13.jpg?s=0123456789012
to generate you own code, where the number after the s needs to be 12 digits for an EAN-13 barcode (the 13th checksum digit is computed automatically if not provided).



Posted by dudek at May 15 21:56 | Leave a comment | permalink link to this entry |
Comments
There are no comments.
Trackbacks
Please send trackback to:/blog//124/tbping
There are no trackbacks.
Post your own response


(Some kind of name is required, will be visible)

Required, whatever you enter will be visible to other users.


(Optional, used for "mailto" link)

Your email address is not required, but if you insert it it will be displayed so people can contact you.


(Optional, will appear as a link)

Leave an URL if you want to provide a relevant link that relates to your comment or identifies you.



The title for your comment.



Your comment goes here. All relevant comments are welcome, except for those that simply promote an irrelevant product or else are used to fraudulently inflate the link count to an irrelevant web page.


(you must preview before posting)




Science Blogs - Blog Top Sites Science Blogs - Blog Catalog Blog Directory Science Blogs - Blog Top Sites Science Blogs - Blog Catalog Blog Directory