#53 py2exe and PIL runtime problem

closed
nobody
None
5
2004-06-11
2004-06-09
Tim Stone
No

Using Python 2.3.4, PIL 1.1.4, and py2exe 0.5.0, the
following script works unless it is compiled with py2exe:

import Image

aimg = Image.new("L", (10,10))
aimg.save("test", "BMP")

print "all done"

A simple setup file is used, as follows:

from distutils.core import setup
import py2exe

setup(console=['testimage.py'])

Output is as expected when running normally. Output is
as follows when run after py2exe setup:

D:\test py2exe\dist>testimage
Traceback (most recent call last):
File "testimage.py", line 4, in ?
File "Image.pyc", line 1145, in save
KeyError: 'BMP'

The results of the py2exe compilation are as follows:

running py2exe
*** searching for required modules ***
*** parsing results ***
creating python loader for extension '_sre'
creating python loader for extension 'datetime'
creating python loader for extension '_imaging'
creating python loader for extension '_tkinter'
creating python loader for extension '_imagingtk'
*** finding dlls needed ***
*** create binaries ***
*** byte compile python files ***
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\PaletteFile.py
to PaletteFile.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\lib-tk\FixTk.py to FixTk.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\copy_reg.py to copy_reg.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\sre_compile.py to sre_compile.
pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\StringIO.py to StringIO.pyc
byte-compiling D:\test py2exe\build\bdist.
win32\winexe\temp\_sre.py to _sre.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\macpath.py to macpath.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\popen2.py to popen2.pyc
byte-compiling D:\test py2exe\build\bdist.
win32\winexe\temp\datetime.py to datetime.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\locale.py to locale.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\ImageChops.
py to ImageChops.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\dummy_thread.py to
dummy_thread.pyc
byte-compiling D:\test py2exe\build\bdist.
win32\winexe\temp\_imaging.py to _imaging.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\calendar.py to calendar.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\GimpGradient
File.py to GimpGradientFile.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\posixpath.py to posixpath.pyc
byte-compiling D:\test py2exe\build\bdist.
win32\winexe\temp\_tkinter.py to _tkinter.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\linecache.py to linecache.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\tempfile.py to tempfile.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\ImageColor.
py to ImageColor.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\ImageFilter.
py to ImageFilter.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\sre_constants.py to
sre_constants.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\re.py to re.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\ntpath.py to ntpath.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\ImageTk.py
to ImageTk.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\stat.py to stat.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\random.py to random.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\lib-tk\Tkinter.py to Tkinter.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\string.py to string.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\atexit.py to atexit.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\warnings.py to warnings.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\UserDict.py to UserDict.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\repr.py to repr.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\ImagePalette.
py to ImagePalette.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\copy.py to copy.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\types.py to types.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\GimpPaletteFi
le.py to GimpPaletteFile.pyc
byte-compiling D:\test py2exe\build\bdist.
win32\winexe\temp\_imagingtk.py to _imagingtk.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\sre.py to sre.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\Image.py to
Image.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\traceback.py to traceback.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\lib-tk\Tkconstants.py to
Tkconstants.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\os2emxpath.py to os2emxpath.
pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\_strptime.py to _strptime.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\colorsys.py to colorsys.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\sre_parse.py to sre_parse.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\os.py to os.pyc
skipping byte-compilation of D:
\PROGRA~1\Python23\lib\site-packages\PIL\ImageTransfo
rm.py to ImageTransform.pyc
*** copy extensions ***
*** copy dlls ***
copying D:
\PROGRA~1\Python23\lib\site-packages\py2exe\run.exe
-> D:\test py2exe\dist\testimage.exe

Discussion

  • Thomas Heller
    Thomas Heller
    2004-06-11

    • status: open --> closed
     
  • Thomas Heller
    Thomas Heller
    2004-06-11

    Logged In: YES
    user_id=11105

    PIL loads it's plugin dynamically, so py2exe cannot include
    the plugins needed. Adding a 'import BmpImagePlugin' to
    your script makes the exe work.