我试图打包一个小脚本,用pylab做一些绘图.我在Linux下使用pyinstaller没有问题,但在Windows 7下我收到错误.在另一台安装了PySide而不安装PyQt的计算机上,包装工作正常.因此,通过删除PyQt我可以让它在我的其他计算机上...

我试图打包一个小脚本,用pylab做一些绘图.我在Linux下使用pyinstaller没有问题,但在Windows 7下我收到错误.在另一台安装了PySide而不安装PyQt的计算机上,包装工作正常.因此,通过删除PyQt我可以让它在我的其他计算机上工作.但是,我想知道是否有另一种解决这个问题的方法,因为我有一些使用PyQt的脚本和一些使用PySide的脚本.我使用cx_freeze得到了类似的错误.
谢谢你的帮助,
丹尼尔
显示问题的示例代码:
from pylab import *
labels = 'Cakes', 'Cookies', 'Biscuits', 'Tarts'
fracs = [27, 33, 14, 19]
pie(fracs, labels=labels, autopct='%1.1f%%', startangle=90)
show()
执行打包程序时产生错误:
WARNING: file already exists but should not: C:\Users\..\Temp\_MEI61562\Include\pyconfig.h
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Workspace\ZLC_python\build\test\out00-PYZ.pyz\pylab", line 1, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Workspace\ZLC_python\build\test\out00-PYZ.pyz\matplotlib.pylab", line 269, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Workspace\ZLC_python\build\test\out00-PYZ.pyz\matplotlib.pyplot", line 93, in <module>
File "C:\Workspace\ZLC_python\build\test\out00-PYZ.pyz\matplotlib.pyplot", line 80, in _backend_selection
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 409, in load_module
module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
ImportError: DLL load failed: The specified procedure could not be found.
通过遵循Pyinstaller –onefile warning pyconfig.h when importing scipy or scipy.signal的建议我摆脱了警告,但错误仍然存??在.
版本:
> Python 2.7.5
> PySide 1.2.1
> PyQt 4.9.6-3
> matplotlib 1.2.1
> numpy 1.7.1
> pyinstaller 2.1
解决方法:
我仔细看了一下pyinstaller文档,找到了pyinstaller的解决方案.我在spec文件的Analysis块中使用了excludes选项:
# -*- mode: python -*-
a = Analysis(['test.py'],
pathex=['C:\\Workspace\\ZLC_python'],
hiddenimports=[],
hookspath=None,
excludes=['PyQt4'],
runtime_hooks=None)
for d in a.datas:
if 'pyconfig' in d[0]:
a.datas.remove(d)
break
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='test.exe',
debug=False,
strip=None,
upx=True,
console=True )
本文标题为:python – 在Windows 7下打包pylab时PySide和PyQt发生冲突


基础教程推荐
- 教你使用Python画棵圣诞树完整代码 2023-08-11
- python-使用串行对象作为参数的多进程 2023-11-12
- Pytorch关于Dataset 的数据处理 2023-08-04
- linux更新python3.7 2023-11-10
- centos 安装python3.6 2023-09-04
- python-如何在测试时可靠地杀死进程? 2023-11-11
- Python 编程语言详细介绍 2023-08-11
- python脚本删除n天前文件可用于windows,linux并且支持跨平台 2023-09-03
- 在Windows的Emacs中运行Python 2023-11-12
- Python 3.7 安装 Centos 2023-09-04