py2exe打包PyQt项目

 打包脚本:

# coding: utf-8

from distutils.core import setup

import py2exe

import sys

 

#this allows to run it with a simple double click.

sys.argv.append('py2exe')

 

script = [{

"script":"sendmail.pyw",

'icon_resources':[(0, 'email.ico'),]

}]

 

py2exe_options = {

"includes":["sip",],

"dll_excludes": ["MSVCP90.dll",]

}

 

setup(windows=script, options={'py2exe':py2exe_options})

特别说明:如果不添加”dll_excludes”: [“MSVCP90.dll”,]选项,可能会出现找不到MSVCP90.dll的错误。

关于这个问题,这里有个讨论:http://stackoverflow.com/questions/323424/py2exe-fails-to-generate-an-executable

 

 

 打包使用email模块的程序,提示缺少email相关模块问题的解决:

 

File “sendmail.pyw”, line 11, in <module>

File “email\mime\text.pyc”, line 10, in <module>

File “email\mime\nonmultipart.pyc”, line 10, in <module>

File “email\mime\base.pyc”, line 9, in <module>

File “email\message.pyc”, line 86, in <module>

File “email\message.pyc”, line 786, in Message

 

手动将email下的文件复制到library.zip中即可。

 

这里有个讨论:http://topic.csdn.net/u/20090204/14/0e7a0086-fb30-4ce9-807a-d1699371dbe4.html

 

 

打包后PyQt框架中使用的ico图标无法显示问题的解决:

py2exe打包的时候漏了Qt的imageformat类库,把PyQt4安装目录下的plugins下的 imageformats文件夹 复制到 打包后的 dist目录下(和程序同级)即可。

文 / admin
LEAVE A REPLY

loading