Resolve warning "A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy"?

Question:

When I import SciPy or a library dependent on it, I receive the following warning message:

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

It’s true that I am running NumPy version 1.23.1, however this message is a mystery to me since I am running SciPy version 1.7.3, which, according to SciPy’s documentation, is compatible with NumPy <1.24.0.

Anyone having this problem or know how to resolve it?

I am using Conda as an environment manager, and all my packages are up to date as far as I know.

  • python: 3.9.12
  • numpy: 1.23.1
  • scipy: 1.7.3

Thanks in advance if anyone has any clues !

Asked By: catlanguage

||

Answers:

According to the setup.py file of the scipy 1.7.3, numpy is indeed <1.23.0. As @Libra said, the docs must be incorrect. You can:

  1. Ignore this warning
  2. Use scipy 1.8
  3. Use numpy < 1.23.0

Edit:

This is now fixed in the dev docs of scipy https://scipy.github.io/devdocs/dev/toolchain.html

Answered By: psarka

I have the same issue.

The scipy 1.7.3 docs specifies
1.16.5 <= numpy <1.24.0 while in scipy 1.7.3 code setup.py and __init__.py we have np_maxversion = '1.23.0'.

As I rely on conda channel defaults to setup Intel MKL libraries for numpy and scipy I decided to pin "numpy>=1.22.3,<1.23.0" until a newer scipy is release on conda channel defaults:

conda create -n myenv python "numpy>=1.22.3,<1.23.0" scipy
Answered By: Maurício Collaça

Since "UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required", you can update the numpy version with the specified range to remove the warning.

According to syntax guidelines of conda and pip, updating your numpy version by

conda install "numpy>=1.16.5,<1.23.0"

or

pip install "numpy>=1.16.5,<1.23.0"

inside your environment will work.

Your numpy will be overwritten by the best-match version (1.22.4) in the specified range. You can double-check the new numpy version by:

conda list numpy

or

pip show numpy

Answered By: Ka Wa Yip
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.