2013-02-11 97 views
3

大家好,感谢您的阅读。我使用pyinstaller包装我的Python代码在一个文件中,但是当我跑我打包的文件我得到以下错误:使用pyinstaller打包:找不到PyQt4模块

Traceback (most recent call last): 
File "<string>", line 21, in <module> 
File "C:\Users\****\Desktop\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 409, in importHook 
ImportError: No module named PyQt4.QtCore 

我不知道这是什么错误是告诉我,特别是因为有在我的桌面上没有dir名称pyinstaller-2.0,我根本没有使用PyQt4。

进口模块:Tkinter, tkFileDialog, tkMessageBox, multiprocessing, os, sys, time, numpy, scipy.weave, pywt, matplotlib.pyplot

我想,因为我以前没遇到此错误的问题是关系到multiprocessing。我使用this recipe正确实施了multiprocessing模块。

回答

3

如果您正在使用PyQt那么唯一的方法导入与PyInstaller模块是使用

from PyQt4 import QtCore, QtGui 

而不是

import PyQt4.QtCore, PyQt4.QtGui 

,你的错误暗示。但是,你说你没有使用PyQt

PyQtmatplotlib一个可选的依赖所以有机会PyInstaller正在检查matplotlib模块,并因此包括PyQt

我建议从构建中排除PyQt模块;在.spec文件,搜索出的Analysis类行 - 就像

Analysis(..., excludes=['PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui']) 

的东西,上面建议编辑excludes关键字ARG。