py2exe: cannot identify image file

D

Daniel Mark

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top