py2exe 打包 PyQt4 的问题
来源:互联网 发布:java处理高并发问题 编辑:程序博客网 时间:2024/05/17 14:15
py2exe 打包注意事项
- 开发环境中只有 PyQt4, 不要安装 Qt 的开发包或者 PySide, 否则打包的 dll 可能会拷贝这两个包的 DLL 而导致程序不能加载运行.
- 注意要拷贝 VS 2008 的运行库.
- 注意要手动拷贝 PyQt4 目录下的 Qt 的 Plugins 目录. 否则 WebKit 不能显示图片文件或者 Phonon 不能播放声音.
- py2exe 打包时不要使用
bundle_files
打包成一个文件, 可能程序运行出现错误. - 找不到
MSVCP90.dll
的话, 在sys.path
中添加路径. - lxml包打包时, 需要在 py2exe 的
options
的packages
中包含, 如果在includes
中包含, 会出现_elementpath
无法 import 的问题. - 如果包含了 WebKit, 还需要在 py2exe
options
的includes
部分包含QNetwork
, 否则 WebKit 不能运行. - 如果包含了 twisted, 由于 twisted 依赖
zope.interface
, 需要包含zope.interface
, 而zope.interface
包名不是标准的 Python 模块名, 导致 py2exe 找不到zope
模块. 解决办法是直接修改系统文件, 在 Python 的 site-packages/zope 目录下创建空的__init__.py
文件. :) 比较 dirty. - 如果使用了 email 模块, 需要在
packages
中包含email
模块. - 如果目标机器不安装 VC 的运行库, 需要自己拷贝 VS 2008 的运行库.
- 即使自己拷贝 VS2008 的运行库, Qt 的 Plugin (包括图片, phonon) 也不会正确加载, 一切的罪魁祸首是 xp 的 embedded manifest 文件,这个问题困惑了我好久! QtWebKit 不能显示jpeg, gif 等图片, phonon 不能发声, 不能显示视频等. 解决办法是: 由于使用自己拷贝的 VS2008 运行库, 需要在每个 plugin 的目录下拷贝一份, 包括
imageformats
和phonon_backend
.
源代码例子如下:
# FILE: setup.pyimport sysfrom glob import globfrom distutils.core import setupsys.path.append(r'c:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT')data_files = ['zh_CN.qm', 'admailer.ico', 'adview.html', 'adview.xls']console = [{'script': 'main.py', 'icon_resources' : [(1, 'admailer.ico')], 'dest_base' : 'avmailer', }]options_py2exe = { 'py2exe' : { 'packages' : ['lxml', 'email'], 'includes': [ 'sip', 'twisted', 'xlrd', 'htmllaundry', 'lxml','zope.interface', 'sqlite3','gzip', 'PyQt4.QtNetwork'], #'dll_excludes' : ['MSVCP90.dll'], 'bundle_files' : 3, 'optimize': 2, } } if sys.platform == 'win32': import py2exe data_files += [ ('Microsoft.VC90.CRT', glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*')), ('imageformats', glob(r'C:\Python27\Lib\site-packages\PyQt4\plugins\imageformats\*.*')), (r'imageformats\Microsoft.VC90.CRT', glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*')), ]import py2exesetup ( name='admailer', version='0.9', packages=[''], url='http://www.adview.cn', license='MIT', author='kerberos', author_email='imkerberos@yahoo.com.cn', description='', options = options_py2exe, console = console, data_files = data_files)
- py2exe 打包 PyQt4 的问题
- PyQt4 QPixmap.load/loadFromData 使用py2exe 打包后无法显示JPEG,gif等图片的问题
- py2exe打包matplotlib和PyQt4
- py2exe打包问题
- py2exe 打包 pyqt程序的图片不显示的问题
- twisted(iocp)程序在用py2exe打包时的问题
- py2exe打包,vista/win7下图标显示问题的解决方案
- py2exe打包,vista/win7下图标显示问题的解决方案
- py2exe打包在Windows7上的图标问题
- py2exe打包的简单使用
- 用pyinstaller打包PyQt4程序遇到的问题及解决办法
- PyQt4及py2exe使用时的一些错误及解决方案
- py2exe打包
- py2exe打包
- py2exe打包
- py2exe打包
- py2exe 打包
- py2exe-为你的py文件打包
- ListView ClassCastException:
- (work and tools)ubuntu vnc的配置
- 公司应用场景分析--公司PBX 总机
- RAII (Resource Acquirement Is Initialization)
- 黑马程序员--面向对象经典小例子
- py2exe 打包 PyQt4 的问题
- LoadView And ViewDidLoad
- Python--良好的代码风格
- (work and tools)ubuntu minicom的配置
- (work and tools)ubuntu p4的用法
- NSURLRequest详解
- Windows 8.1 .Net Framework 3.5 Installation
- Entity Framework Code First数据库自动更新
- 使用指针实现学生成绩的录入,求最高分最低分、平均值和排序