NumPy 1.21.2 可能还不支持 Python 3.10

NumPy 1.21.2 may not yet support Python 3.10

Python 3.10 已发布,当我尝试安装 NumPy 时,它给了我这个:NumPy 1.21.2 may not yet support Python 3.10.。我该怎么办?

如果在 Windows 上,numpy 尚未发布 Python 3.10 的预编译轮。但是,您可以尝试 https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy 提供的非官方轮子。 具体寻找

  • numpy‑1.21.2+mkl‑cp310‑cp310‑win_amd64.whl
  • numpy‑1.21.2+mkl‑cp310‑cp310‑win32.whl

取决于您的系统架构。

下载文件后转到下载目录并运行 pip install "<filename>.whl"。)

(我亲自安装了 numpy‑1.21.2+mkl‑cp310‑cp310‑win_amd64.whl,它对我有用。)

因为您使用的是 MS-Windows,您也可以使用 pipwin - this windows only utility is pip installable and can download and install a number of "unofficial" builds (provided by the excellent Christoph Gohlke) of scientific from the https://www.lfd.uci.edu/~gohlke/pythonlibs/,但无需猜测要下载和安装的文件。

会话可能 运行:

pip install pipwin
pipwin install numpy

或者您可以使用 py 启动器,如下所示:

py -3.10 -mpip install pipwin
py -3.10 -mpipwin refresh
py -3.10 -mpipwin install numpy

中间步骤告诉 pipwin 填充当前可用的列表。

如果你不介意使用 Docker 和 Debian,官方 python:3.10 (==python:3.10-bullseye) docker 容器已经 pip安装。 numpy 等一些软件包可以使用 pip install 和 运行 在 python 3.10 下安装(不过祝其他软件包好运:)。

这是一些 PoC 和 numpy 确实有效的证据:

$ docker run -it --rm --name python310 -u 0 python:3.10 bash -c 'pip --version; pip install numpy --user --no-cache; pip show numpy; python -c "import numpy as np; print(np.ones(5))"'

..应该输出:

pip 21.2.4 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
Collecting numpy
  Downloading numpy-1.21.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.9 MB)
     |████████████████████████████████| 15.9 MB 36.9 MB/s 
Installing collected packages: numpy
  WARNING: The scripts f2py, f2py3 and f2py3.10 are installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.21.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Name: numpy
Version: 1.21.4
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: 
License: BSD
Location: /root/.local/lib/python3.10/site-packages
Requires: 
Required-by: 
[1. 1. 1. 1. 1.]