Python 在Windows 7下打包pylab时,PySide和PyQt发生冲突

Python 在Windows 7下打包pylab时,PySide和PyQt发生冲突,python,matplotlib,pyqt4,pyside,pyinstaller,Python,Matplotlib,Pyqt4,Pyside,Pyinstaller,我试图打包一个小脚本,用pylab进行一些绘图。我在Linux下使用pyinstaller没有问题,但在Windows7下我得到了一个错误。在另一台安装了PySide但未安装PyQt的计算机上,打包工作正常。因此,通过删除PyQt,我可以让它在我的另一台计算机上工作。然而,我想知道是否有其他方法可以解决这个问题,因为我有一些使用PyQt的脚本和一些使用PySide的脚本。我使用cx_freeze时也遇到了类似的错误 谢谢你的帮助, 丹尼尔 显示问题的示例代码: from pylab import

我试图打包一个小脚本,用pylab进行一些绘图。我在Linux下使用pyinstaller没有问题,但在Windows7下我得到了一个错误。在另一台安装了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.
警告:文件已存在,但不应存在:C:\Users\..\Temp\\u MEI61562\Include\pyconfig.h
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\Python27\Lib\site packages\PyInstaller\loader\pyi\u importers.py”,第270行,在load\u模块中
exec(字节码、模块、指令)
文件“C:\Workspace\ZLC\u python\build\test\out00 PYZ.PYZ\pylab”,第1行,在
文件“C:\Python27\Lib\site packages\PyInstaller\loader\pyi\u importers.py”,第270行,在load\u模块中
exec(字节码、模块、指令)
文件“C:\Workspace\ZLC\u python\build\test\out00 PYZ.PYZ\matplotlib.pylab”,第269行,在
文件“C:\Python27\Lib\site packages\PyInstaller\loader\pyi\u importers.py”,第270行,在load\u模块中
exec(字节码、模块、指令)
文件“C:\Workspace\ZLC\u python\build\test\out00 PYZ.PYZ\matplotlib.pyplot”,第93行,在
文件“C:\Workspace\ZLC\u python\build\test\out00 PYZ.PYZ\matplotlib.pyplot”,第80行,在\u backend\u选项中
文件“C:\Python27\Lib\site packages\PyInstaller\loader\pyi\u importers.py”,第409行,在load\u模块中
module=imp.load\u module(全名、fp、文件名、self.\u c\u ext\u元组)
ImportError:DLL加载失败:找不到指定的过程。
通过遵循来自的建议,我摆脱了警告,但错误依然存在

版本:

  • 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的解决方案。我在等级库文件的分析块中使用了“排除”选项:

# -*- 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 )

我只是尝试按照中的说明删除PyQt4,但在使用pyinstaller打包的过程中出现了错误。