Py2exe executable not loading images

Anand anandpillai6 at yahoo.com
Thu Oct 17 02:38:05 EDT 2002


Hi Thomas

 Thanks a lot. It worked. I have similar problems in the module
os, when using the os.listdir() function. Any ideas about it ?

 Here is the error report:

  "LookupError: no codec search functions registered: can't find encoding"

  I am passing a unicode string to the function os.listdir(dir) which works
well in normal python interpreter.

Thanks & Regards,

Anand 

Thomas Heller <thomas.heller at ion-tof.com> wrote in message news:<bs61ds3y.fsf at ion-tof.com>...
> 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:
> http://www.cs.washington.edu/homes/dougz/slithy/py2exe/
> 
> 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
> 
> HTH,
> 
> Thomas



More information about the Python-list mailing list