Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PIL and py2exe Issues

14 views
Skip to first unread message

Kevin Dahlhausen

unread,
Jun 4, 2003, 2:02:18 PM6/4/03
to
Anyone come across the problem of PIL not being able to identify image
files once it's compiled with py2exe? Do I need to manually add some
plugins to the setup or something?

Traceback (most recent call last):
File "<string>", line 65, in ?
File "<string>", line 31, in __init__
File "PictureList.pyc", line 42, in __init__
File "PictureInfo.pyc", line 23, in __init__
File "Image.pyc", line 1571, in open
IOError: cannot identify image file

Versions:
Python 2.2.2 (#37)
PIL 1.1.4

Thanks

Fredrik Lundh

unread,
Jun 5, 2003, 1:54:13 AM6/5/03
to
Kevin Dahlhausen wrote:

> Anyone come across the problem of PIL not being able to identify image
> files once it's compiled with py2exe?

google knows... ;-)

> Do I need to manually add some plugins to the setup or something?

PIL scans sys.path for plugins (*ImagePlugin files). When running under
py2exe (or any other wrapper), you have to import them yourself. Just
add import statements to your main program for all the formats you need:

import JpegImagePlugin
import PngImagePlugin
import BmpImagePlugin
import GifImagePlugin
# etc

(to get a complete list, look in the PIL package directory)

</F>


Anand Pillai

unread,
Jun 5, 2003, 8:21:53 AM6/5/03
to
I had faced similar problems sometime back .
What you need to do is perform a separate import
of the image plugin modules which you need in your
program before you process it using PIL.

i.e, instead of just
import Image

you need to add

import JpegImagePlugin #for jpeg
import TgaImagePlugin #for tga
import PngImagePlugin #for png
...

You need to do this for each image plugin you need
PIL support for. (This question has been asked manytimes
in this group before, I myself have asked it a couple of
times)

You can take a look at PyWiew source code in my homepage
for details.

Regards

Anand Pillai

http://members.lycos.co.uk/anandpillai


kdah...@yahoo.com (Kevin Dahlhausen) wrote in message news:<283adf56.03060...@posting.google.com>...

Kevin Dahlhausen

unread,
Jun 5, 2003, 9:11:33 AM6/5/03
to
Thanks - that makes sense now.

Kevin Dahlhausen

unread,
Jun 5, 2003, 4:08:48 PM6/5/03
to
> You need to do this for each image plugin you need
> PIL support for. (This question has been asked manytimes
> in this group before, I myself have asked it a couple of
> times)

Thanks - I did search but I guess not long enough for it. It's a good
thing to remember in general for py2exe.

0 new messages