在使用cx_freeze和and时,我在编译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.在查看_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配置文件有问题。可能不包括在构建过程中。我是个新手,希望更有经验的人在使用can生成构建时能对此有所了解。
顺便说一句,使用中的枕木是从二进制文件这里安装的。
发布于 2015-09-28 11:58:34
我也有过同样的问题。我将此代码添加到由setup.py生成的cx_freeze中:
import scipy
includefiles_list=[]
scipy_path = dirname(scipy.__file__)
includefiles_list.append(scipy_path)然后,使用includefiles_list作为build_exe参数的一部分:
build_options = dict(packages=[], include_files=includefiles_list)
setup(name="foo", options=dict(build_exe=build_options))发布于 2017-08-02 17:06:17
我添加了相同的问题,并使用fepzzz方法解决了这个问题,并包含了一些丢失的包:
additional_mods = ['numpy.matlib', 'multiprocessing.process']
includefiles = [(r'C:\Anaconda3\Lib\site-packages\scipy')]
setup(xxx, options={'build_exe': {'includes': additional_mods, 'include_files': includefiles}})并使用5.0.2版的cx-冻结软件包,解决了导入multiprocessing.process时出现的错误
https://stackoverflow.com/questions/32694052
复制相似问题