I’m trying to use Py2exe to convert a .py file to an .exe file. My program uses several modules from PIL
This is what my .py file imports from PIL (snippet):
import Tkinter, re, random, struct
from PIL import ImageTk, Image, ImageDraw, ImageGrab
This is the code I use to convert my .py file to an .exe:
from distutils.core import setup
import py2exe
setup(windows=[{"script": r'C:\Python26\blur.py'}],
options={r"py2exe":{r"includes": r'Tkinter',
r"includes": r'random',
r"includes": r're',
r"includes": r'struct',
r"includes": r'PIL',
}})
Problems arise when I try to run my .exe. When I click on the .exe, the program fails to start.
I found this:
http://www.py2exe.org/index.cgi/py2exeAndPIL
However, I’m uncertain of it’s relevancy. Seeing as my program does not load any images of any file format, but instead creates one using the Image.new() method.
Snippet:
self.im = Image.new('RGB', (w, h), self.Hex )
This is in Windows 7, if it makes a difference.
Since the problem is apparently due to PIL’s internal initialisation routines rather than anything specific your application does, I suggest trying the workaround described at the link you found and seeing if it helps.
If that still doesn’t work, I also suggest running your application from the command line rather than clicking it, to see if you get a helpful error message displayed.