gpt4 book ai didi

python - Scipy 错误 : numpy. dtype 大小已更改,可能表示二进制不兼容(以及相关的奇怪行为)

转载 作者:太空狗 更新时间:2023-10-29 20:15:39 26 4
gpt4 key购买 nike

我正在 OS X 10.9.4 上安装 numpy/scipy/scikit-learn,但收到有关“numpy.dtype 大小已更改,可能表明二进制不兼容”的错误。

这是我构建 repo 所做的工作:

mkvirtualenv thm
workon thm
pip install numpy scipy pandas ipython # and some other stuff
cd /path/to/our/repo
# run tests

这是相关警告的回溯摘录(由于我们在测试开始时使用了 warnings.simplefilter('error') 而变成了错误):

======================================================================
ERROR: Failure: RuntimeWarning (numpy.dtype size changed, may indicate binary in
compatibility)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ben/.virtualenvs/thm/lib/python2.7/site-packages/nose/loader.py",
line 414, in loadTestsFromName
addr.filename, addr.module)
File "/Users/ben/.virtualenvs/thm/lib/python2.7/site-packages/nose/importer.py
", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Users/ben/.virtualenvs/thm/lib/python2.7/site-packages/nose/importer.py
", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/ben/code/thm/alpha/prosper/base/stats/test_auc.py", line 3, in <m
odule>
import sklearn.metrics
File "/Users/ben/.virtualenvs/thm/lib/python2.7/site-packages/sklearn/metrics/
__init__.py", line 6, in <module>
from .metrics import (accuracy_score,
File "/Users/ben/.virtualenvs/thm/lib/python2.7/site-packages/sklearn/metrics/metrics.py", line 27, in <module>
from scipy.spatial.distance import hamming as sp_hamming
File "/Users/ben/.virtualenvs/thm/lib/python2.7/site-packages/scipy/spatial/__init__.py", line 90, in <module>
from .ckdtree import *
File "__init__.pxd", line 155, in init scipy.spatial.ckdtree (scipy/spatial/ckdtree.c:20570)
RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility

有人告诉我这个警告是由于 scipy 是针对与安装版本不同的 numpy 版本编译的。但是,我以我认为非常标准的方式使用 pip 安装了它们,所以我认为这应该不是问题。

奇怪的是,尽管作为一个整体运行我们的整个测试套件(通过 python -m unittest discover )会出现这些错误,但运行单独的测试(通过 python -m unittest <module> )工作正常。

根据测试,这里有一些相关的版本信息:

numpy version 1.9.0 (rev 07601a64cdfeb1c0247bde1294ad6380413cab66)
scipy version 0.14.0 (built against numpy 1.9.0)
sklearn version 0.15.2
pandas version 0.14.1

很高兴根据要求提供更多信息!

最佳答案

您是如何构建 sklearn 0.14.1 的?您是否使用与 scipy 相同版本的 numpy 来构建它?

最新版本的 scikit-learn、scipy 和 numpy 具有预构建包。特别是 scikit-learn 0.15.2 应该与 numpy 1.7+ 二进制兼容。我认为 scipy 0.14.0 也是如此,但你说你自己从源代码构建它,这不是 pip 默认应该做的(它应该只安装预构建的 whl 包)。

编辑:您是否尝试过:

pip install -U scipy scikit-learn pandas

确保您为这些软件包使用最新稳定版本的 whl?

编辑:下面的评论包含有效的实际答案,并且大概是接受该答案的原因。即:

pip uninstall -y scipy scikit-learn
pip install --no-binary scipy scikit-learn

关于python - Scipy 错误 : numpy. dtype 大小已更改,可能表示二进制不兼容(以及相关的奇怪行为),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25752444/

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