在ubuntu 12.04下使用cx_freeze
。包的生成是
完成没有任何错误,但当我尝试运行包作为
独立,我收到以下错误:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts /Console.py",
line 27, in <module>
exec code in m.__dict__
m m File "Setup_cx_freeze.py", line 3, in <module>
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/__init__.py",
line 4, in <module>
from cx_Freeze.dist import *
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/dist.py",
line 3, in <module>
import distutils.command.install
File "/usr/lib/python2.7/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
File "/usr/lib/python2.7/site.py", line 562, in <module>
main()
File "/usr/lib/python2.7/site.py", line 540, in main
abs__file__()
File "/usr/lib/python2.7/site.py", line 100, in abs__file__
m.__file__ = os.path.abspath(m.__file__)
File "/usr/lib/python2.7/email/__init__.py", line 79, in __getattr__
__import__(self.__name__)
ImportError: No module named image
我认为要关注的是最后一句话。 "ImportError: No module named image."
应用程序在纯python环境中运行没有任何问题 那么为什么在将其作为“冻结”包运行时会出现错误?该 生成冻结包时会以某种方式引入错误。
答案 0 :(得分:2)
我最后通过在setup.py脚本构建exe选项中明确包含“email.mime”包来修复此问题。
答案 1 :(得分:1)
缺少'图像'只是问题的第一部分。尝试将其添加到您的代码中:
from email.mime.image import MIMEImage
from email.mime.audio import MIMEAudio
from email.mime.message import MIMEMessage
解决了'image','audio'和'message'的问题。
答案 2 :(得分:-1)
通过安装Python Imaging Library解决了这个问题:http://www.pythonware.com/products/pil/
1)python setup.py build
2)sudo python setup.py install