【问题标题】:Problems with PIL and py2exePIL 和 py2exe 的问题
【发布时间】:2011-02-01 03:44:34
【问题描述】:

我正在尝试使用 Py2exe 将 .py 文件转换为 .exe 文件。我的程序使用了 PIL 的几个模块

这是我从 PIL (sn-p) 导入的 .py 文件:

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 中,如果它有所作为的话。

【问题讨论】:

    标签: python tkinter python-imaging-library py2exe


    【解决方案1】:

    由于问题显然是由于 PIL 的内部初始化例程而不是您的应用程序所做的任何特定操作,我建议尝试您找到的链接中描述的解决方法,看看它是否有帮助。

    如果这仍然不起作用,我还建议从命令行运行您的应用程序而不是单击它,以查看是否会显示有用的错误消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-23
      • 1970-01-01
      • 1970-01-01
      • 2011-07-15
      • 2010-11-26
      • 1970-01-01
      相关资源
      最近更新 更多