py2exe: cannot identify image file
Daniel Mark
danielmarkhot at gmail.com
Sat Aug 19 01:30:46 EDT 2006
Hello all:
I have following code that works well under command line, but it
doesn't work after I convert it
as exe application.
############### file: testPath.py
import getopt, math, sys, os, Image, ImageDraw, aggdraw
def processline():
try:
imgDir = 'c:/'
lumenImageName = '00299.jpg'
im = Image.open(os.path.join(imgDir, lumenImageName))
arrowImageName = '00299.png'
im.save(os.path.join(imgDir, arrowImageName), "PNG")
print lumenImageName
except IOError, e:
print e
def main():
processline()
if __name__ == '__main__':
main()
print 'Done'
else:
print 'non main'
############### setup.py
from distutils.core import setup
import py2exe
options = {
"bundle_files": 1,
# "ascii": 1, # to make a smaller executable, don't include the
encodings
"compressed": 1, # compress the library archive
}
setup(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
version = "1.0",
description = "testPath",
name = "testPath",
options = {"py2exe": options},
zipfile = None, # append zip-archive to the executable.
# targets to build
console=['testPath.py'],
)
###########################
It works under command line
C:\>python testPath.py
00299.jpg
Done
But it doesn't work after I convert it as EXE application
The error message I got from screen is as follows:
C:\dist>testPath.exe
cannot identify image file
Done
It seems that function 'Image.open' cannot read image file under EXE
application.
What should I do for this problem?
Thank you
-Daniel
More information about the Python-list
mailing list