gpt4 book ai didi

Scipy 和 CX_freeze - 导入 scipy : you cannot import scipy while being in scipy source directory 时出错

转载 作者:行者123 更新时间:2023-12-04 10:36:28 27 4
gpt4 key购买 nike

我在使用 cx_freeze 和 scipy 时无法编译 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 是从二进制文件安装的 here .

最佳答案

我有同样的问题。我将此代码添加到 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))

关于Scipy 和 CX_freeze - 导入 scipy : you cannot import scipy while being in scipy source directory 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32694052/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com