GTK 应用程序的 py2exe 版本无法读取 png 文件
我正在制作我的应用程序的 py2exe 版本。 Py2exe 无法复制某些内容 我原来的应用程序可以很好地加载 .png
文件,但 exe 版本却不能:
Traceback (most recent call last):
File "app.py", line 1, in <module>
from gui.main import run
File "gui\main.pyc", line 14, in <module>
File "gui\controllers.pyc", line 10, in <module>
File "gui\utils\images.pyc", line 78, in <module>
☺
File "gui\utils\images.pyc", line 70, in GTK_get_pixbuf
☺§☺▲☻
File "gui\utils\images.pyc", line 38, in PIL_to_pixbuf
gobject.GError: Image type 'png' is not supported
知道我应该强制 py2exe 包含什么吗?
I'm working on making a py2exe version of my app. Py2exe fails at copying some
modules in. My original app loads .png
files fine, but the exe version does not:
Traceback (most recent call last):
File "app.py", line 1, in <module>
from gui.main import run
File "gui\main.pyc", line 14, in <module>
File "gui\controllers.pyc", line 10, in <module>
File "gui\utils\images.pyc", line 78, in <module>
☺
File "gui\utils\images.pyc", line 70, in GTK_get_pixbuf
☺§☺▲☻
File "gui\utils\images.pyc", line 38, in PIL_to_pixbuf
gobject.GError: Image type 'png' is not supported
Any idea what I should force py2exe to include?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是 PIL 和 py2exe
PIL(python 图像库)动态导入其插件,而 py2exe 无法识别,因此它不包含 .exe 文件中的插件。
解决方法(希望如此!)是在您的 .py 文件之一中显式导入驱动程序,
这意味着 py2exe 肯定会包含该插件。
Image._initialized
位停止 PIL 扫描更多插件。这里是 py2exe wiki 中的文档,详细解释了这一点
This is a known problem with PIL and py2exe
PIL (python image library) imports its plugins dynamically which py2exe doesn't pick up on, so it doesn't include the plugins in the .exe file.
The fix (hopefully!) is to import the drivers explicitly like this in one of your .py files
That will mean that py2exe will definitely include the plugin. The
Image._initialized
bit stops PIL scanning for more plugins.Here are the docs from the py2exe wiki explaining this in full
这是什么平台?
最近我认为他们改进了 windows 上的 png 支持,
所以你使用的 pygtk 版本也是相关的。
http://aruiz.typepad.com/siliconisland/2008/ 02/再见-zlib-li.html
What platform is this?
Lately I think they improved the png support on windows,
so the version of pygtk you're using is pertinent also.
http://aruiz.typepad.com/siliconisland/2008/02/goodbye-zlib-li.html
确保在安装应用程序时捆绑加载程序。 Py2exe 不会知道这些,但它们是 GTK 所需的一部分,并且位于其余 GTK“数据”文件所在的位置。
来自 http://unpythonic.blogspot .com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html
保留版权。
Make sure you bundle the loaders when you install your application. Py2exe won't know about these, but they are a needed part of GTK, and live where the rest of the GTK "data" files live.
From http://unpythonic.blogspot.com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html
Copyright retained.