PIL 和 py2exe 的问题
我正在尝试使用 Py2exe 将 .py 文件转换为 .exe 文件。我的程序使用 PIL 中的多个模块
这是我的 .py 文件从 PIL 导入的内容(片段):
import Tkinter, re, random, struct
from PIL import ImageTk, Image, ImageDraw, ImageGrab
这是我用来将 .py 文件转换为 .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',
}})
当我尝试运行 .exe 时出现问题。当我单击 .exe 时,程序无法启动。
我发现了这个: http://www.py2exe.org/index.cgi/py2exeAndPIL
但是,我'我不确定它的相关性。我的程序不会加载任何文件格式的任何图像,而是使用 Image.new() 方法创建一个图像。
摘录:
self.im = Image.new('RGB', (w, h), self.Hex )
这是在 Windows 7 中,如果它有所不同的话。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于问题显然是由于 PIL 的内部初始化例程造成的,而不是您的应用程序执行的任何特定操作,因此我建议尝试您找到的链接中描述的解决方法,看看它是否有帮助。
如果仍然不起作用,我还建议从命令行运行应用程序而不是单击它,以查看是否显示有用的错误消息。
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.