【问题标题】:PySide and PyQt clash when packaging pylab under Windows 7Windows 7下打包pylab时PySide和PyQt冲突
【发布时间】:2013-12-17 10:04:25
【问题描述】:

我尝试打包一个用 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

【问题讨论】:

标签: python matplotlib pyqt4 pyside pyinstaller


【解决方案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 )

【讨论】:

    猜你喜欢
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 2012-02-04
    • 1970-01-01
    • 2011-06-09
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    相关资源
    最近更新 更多