我有一个使用 Pyinstaller 的已建立 Python 应用程序的构建脚本。这个脚本已经运行了一年多。然后今天,我在此应用程序的源文件之一中添加了以下行
import scipy.stats
因为我想使用scipy.stats.linregress。现在,这会导致构建脚本崩溃,并出现一个很长的错误回溯(显然是通过一系列相互导入的模块返回)以结束
File "C:\Users\462974\Documents\Local Sandbox\fof\TRUNK\programs\CDFParsing\build\pyi.win32\CDFGUI\outPYZ1.pyz/scipy.sparse.csgraph", line 148, in <module>
File "C:\Python27\pyinstaller-1.5\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python27\pyinstaller-1.5\iu.py", line 495, in doimport
mod = importfunc(nm)
File "C:\Python27\pyinstaller-1.5\iu.py", line 297, in getmod
mod = owner.getmod(nm)
File "C:\Python27\pyinstaller-1.5\archive.py", line 468, in getmod
return iu.DirOwner.getmod(self, self.prefix+'.'+nm)
File "C:\Python27\pyinstaller-1.5\iu.py", line 109, in getmod
mod = imp.load_module(nm, fp, attempt, (ext, mode, typ))
File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path (scipy\sparse\csgraph\_shortest_path.c:14224)
File "C:\Python27\pyinstaller-1.5\iu.py", line 455, in importHook
raise ImportError, "No module named %s" % fqname
ImportError: No module named scipy.sparse.csgraph._validation
这令人费解,因为位于 C:\Python27\Lib\site-packages\scipy\sparse\csgraph_validation.py 的模块非常存在。为什么将 scipy 添加到我的构建中会破坏它(导入 numpy 工作得很好),它会找不到它吗?