如何在 Google Colab 上安装最新版本的软件包(存在于 PyPI 上,但在 Colab 索引中缺失)?

How to install latest versions of packages on Google Colab (exists on PyPI, but missing on Colab index)?

我需要根据某些 PyPI 包的最新版本执行一些预处理。例如:scipy 版本 1.8.0。此软件包版本已于 PyPI on February 5th 2022.

发布

我正在尝试通过 pip 在 Google Colab 上安装这个包:

# Specifying the index explicitly to ensure we're using PyPI directly.
!pip install -i https://pypi.python.org/simple scipy==1.8.0

不幸的是,这个错误是:

Looking in indexes: https://pypi.python.org/simple
ERROR: Could not find a version that satisfies the requirement scipy==1.8.0 (from versions: 0.8.0, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.13.2, 0.13.3, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 1.0.0b1, 1.0.0rc1, 1.0.0rc2, 1.0.0, 1.0.1, 1.1.0rc1, 1.1.0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0rc1, 1.4.0rc2, 1.4.0, 1.4.1, 1.5.0rc1, 1.5.0rc2, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6.0rc1, 1.6.0rc2, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.7.0rc1, 1.7.0rc2, 1.7.0, 1.7.1, 1.7.2, 1.7.3)
ERROR: No matching distribution found for scipy==1.8.0

即使 scipy 1.8.0 clearly is on the https://pypi.python.org/simple index,我也没有看到 Colab,最新的可用版本已经几个月了。

有没有办法在 Colab 上 pip 安装最新的软件包版本?

如果你在这里查看文件

https://pypi.org/project/scipy/1.8.0/#files

您会看到它们仅适用于 Python 3.8 及更高版本。

因此您需要将 Python 升级到 3.8 或从源代码编译 scipy 1.8.0。