在Google Colab安装StellarGraph[demos]==1.2.1失败,求解决方案
问题描述
尝试在Google Colab中安装StellarGraph软件包,执行的安装代码如下:
# install StellarGraph if running on Google Colab import sys if 'google.colab' in sys.modules: %pip install -q stellargraph[demos]==1.2.1
执行后触发如下错误:
ERROR: Ignored the following versions that require a different python version: 0.10.0 Requires-Python >=3.6.0, <3.8.0; 0.11.0 Requires-Python >=3.6.0, <3.8.0; 0.11.1 Requires-Python >=3.6.0, <3.8.0; 0.4.0 Requires-Python >=3.6,<3.7; 0.4.0b0 Requires-Python >=3.6,<3.7; 0.4.1 Requires-Python >=3.5.0, <3.7.0; 0.5.0 Requires-Python >=3.5.0, <3.7.0; 0.6.0 Requires-Python >=3.5.0, <3.7.0; 0.6.1 Requires-Python >=3.5.0, <3.7.0; 0.7.0 Requires-Python >=3.5.0, <3.8.0; 0.7.1 Requires-Python >=3.5.0, <3.8.0; 0.7.2 Requires-Python >=3.5.0, <3.8.0; 0.7.3 Requires-Python >=3.5.0, <3.8.0; 0.8.0 Requires-Python >=3.5.0, <3.8.0; 0.8.1 Requires-Python >=3.5.0, <3.8.0; 0.8.2 Requires-Python >=3.5.0, <3.8.0; 0.8.3 Requires-Python >=3.5.0, <3.8.0; 0.8.4 Requires-Python >=3.5.0, <3.8.0; 0.9.0 Requires-Python >=3.6.0, <3.8.0; 1.0.0 Requires-Python >=3.6.0, <3.8.0; 1.0.0rc1 Requires-Python >=3.6.0, <3.8.0; 1.1.0 Requires-Python >=3.6.0, <3.9.0; 1.2.0 Requires-Python >=3.6.0, <3.9.0; 1.2.1 Requires-Python >=3.6.0, <3.9.0 ERROR: Could not find a version that satisfies the requirement stellargraph[demos]==1.2.1 (from versions: none) ERROR: No matching distribution found for stellargraph[demos]==1.2.1
需要解决:
- 安装失败的修复方案
- 是否需要额外安装组件
- 软件包的维护状态
解决方案
核心原因
Google Colab当前默认Python版本已高于StellarGraph 1.2.1要求的<3.9.0版本限制,导致pip无法找到匹配的安装包。
修复方案
方案一:切换到兼容的Python版本
在Colab中切换到Python 3.8:
- 运行以下代码选择Python版本:
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 !sudo update-alternatives --config python3
执行后在弹出的选项中选择Python 3.8,然后点击Colab界面的“重启运行时”按钮。
2. 重启完成后,重新执行原安装命令即可。
方案二:安装社区维护分支
StellarGraph官方版本已停止更新,社区维护的stellargraph2分支支持Python 3.8+,适配Colab当前环境,无需切换版本,安装命令:
%pip install -q stellargraph2[demos]
额外组件说明
无论使用官方1.2.1版本还是社区分支,安装命令中的[demos]已经包含了运行示例所需的所有依赖组件,无需额外安装核心组件。
维护状态
- StellarGraph官方版本(1.2.1及更早)已停止维护,最后一次更新在2021年左右。
- 社区维护的
stellargraph2分支仍在持续更新,适配新的Python版本和依赖库。
内容的提问来源于stack exchange,提问作者Sergio Mora
相关产品推荐
相关产品推荐

