| Store | Cart

Py2exe executable not loading images

From: Thomas Heller <thom...@ion-tof.com>
11 Oct 2002 15:26:09 +0200
anandpillai6 at yahoo.com (Anand) writes:

>       I have a simple viewer class in python using wxPython and PIL.> The code uses PIL Image class to open an image and wxPython classes> namely wxFrame, wxBitmap, wxImage to paint it on to a wxPanel.
>  >      The code works fine for all images when run as a python script.> When I create a win32 executable using py2exe and setup.py, the> Image class fails with a message <reproduced here>> > <Quote>> File "<string>", line 453, in OpenImage> File "PIL\Image.pyc", line 960, in open> IOError: cannot identify image file> </Quote>> 
A simple Web search finds several pages offering solutions to this
problem. The best one I could find is from douglas zongker:

He writes:

   Statically load PIL image formats. Slithy uses the Python Imaging
   Library to read image files. Normally PIL dynamically loads plugins
   for the different file formats as it needs them; this scheme won't
   work with py2exe.  At the top of your main script, add a blob of
   code that looks like this:

    import Image

    import JpegImagePlugin    # import drivers for every image format you use
    import TgaImagePlugin
    import PngImagePlugin
    import GifImagePlugin

    Image._initialized = 1



Recent Messages in this Thread
Anand Oct 11, 2002 12:59 pm
Thomas Heller Oct 11, 2002 01:26 pm
Anand Oct 17, 2002 06:38 am
Thomas Heller Oct 17, 2002 10:29 am
Fredrik Lundh Oct 11, 2002 02:15 pm
Messages in this thread