解决警告“NumPy 版本 >=1.16.5 和 <1.23.0 is required for this version of SciPy"?

问题描述 投票:0回答:4

当我导入 SciPy 或依赖于它的库时,我收到以下警告消息:

UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.1

确实,我正在运行 NumPy 版本 1.23.1,但是这条消息对我来说是个谜,因为我正在运行 SciPy 版本 1.7.3,根据 SciPy 的文档,它与 NumPy <1.24.0.

兼容

有人遇到这个问题或者知道如何解决吗?

我使用 Conda 作为环境管理器,据我所知,我的所有软件包都是最新的。

  • 蟒蛇:3.9.12
  • numpy:1.23.1
  • scipy:1.7.3

如果有人有任何线索,请提前致谢!

python numpy scipy conda
4个回答
10
投票

根据scipy 1.7.3的setup.py文件来看,numpy确实是

<1.23.0
。正如@Libra 所说,文档一定是不正确的。你可以:

  1. 忽略此警告
  2. 使用 scipy 1.8
  3. 使用numpy < 1.23.0

编辑

此问题现已在 scipy 的开发文档中修复 https://scipy.github.io/devdocs/dev/toolchain.html


7
投票

我也有同样的问题。

scipy 1.7.3 文档指定

1.16.5 <= numpy <1.24.0
在 scipy 1.7.3 代码中setup.py__init__.py我们有
np_maxversion = '1.23.0'

由于我依靠

conda channel defaults
为 numpy 和 scipy 设置英特尔 MKL 库,我决定固定
"numpy>=1.22.3,<1.23.0"
,直到在
conda channel defaults
上发布更新的 scipy:

conda create -n myenv python "numpy>=1.22.3,<1.23.0" scipy

5
投票

由于“UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required”,您可以使用指定范围更新numpy版本以删除警告。

根据condapip的语法指南,通过

更新你的numpy版本

conda install "numpy>=1.16.5,<1.23.0"

pip install "numpy>=1.16.5,<1.23.0"

在您的环境中将会起作用。

您的 numpy 将被指定范围内的最佳匹配版本(

1.22.4
)覆盖。您可以通过以下方式仔细检查新的 numpy 版本:

conda list numpy

pip show numpy


0
投票

对于我类似的问题 pip install "numpy>=1.16.5,<1.23.0" That works too.

© www.soinside.com 2019 - 2024. All rights reserved.