我在使用cx_freeze和scipy编译exe时遇到了问题。特别是,我的脚本使用了:
构建过程似乎已经成功完成,但是当我尝试运行编译后的exe文件时,会出现以下错误信息。
from scipy.interpolate import griddata
构建过程似乎已经成功完成,但是当我尝试运行编译后的exe文件时,会出现以下错误信息。
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "gis_helper.py", line 13, in <module>
File "C:\Python27\lib\site-packages\scipy\__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
查看scipy\_init\_\_.py文件后,可以看到以下内容:
if __SCIPY_SETUP__:
import sys as _sys
_sys.stderr.write('Running from scipy source directory.\n')
del _sys
else:
try:
from scipy.__config__ import show as show_config
except ImportError:
msg = """Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter."""
raise ImportError(msg)
我不确定问题出在哪里,但是看起来错误是因为scipy配置文件有问题。可能没有被包含在构建过程中。我是一个新手,希望有更多经验的使用cxfreeze生成构建的人可以解决这个问题。
顺便说一下,使用的scipy是从这里下载的二进制文件安装的。
ImportError: No module named 'C:\\***\\***\\Python27\\lib\\site-packages\\scipy
。 - Bridgekeeper