【发布时间】:2022-11-23 18:23:03
【问题描述】:
我想更改我的 Google Colab 上的 python 版本。 目前,它正在运行 python 3.7:
[In]: ! python --version
[Out]: Python 3.7.13
我想要 python 3.10,所以我按照this post中的说明进行操作:
! sudo apt-get update -y
! sudo apt-get install python3.10
! sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
! sudo update-alternatives --config python3
这里打印了一个列表,我选择python 3.10。然后
! sudo apt install python3-pip
现在,当我查询 python 版本时,它显示 3.10:
[In]: ! python --version
[Out]: Python 3.10.6
到目前为止,一切都很好!但,现在有两个问题:
-
pip 似乎完全坏了;我无法 pip 安装任何东西,例如
!pip install gym和!pip3 install gym都出现以下错误:AttributeError: module 'collections' has no attribute 'MutableMapping'- Python 版本显示 3.10,但似乎还是 3.7,因为较新的语法会引发语法错误,例如:
[In]: (a := 3) [Out]: SyntaxError: invalid syntax[In]: a: list[int] = [1] [Out]: TypeError: 'type' object is not subscriptable
【问题讨论】:
-
@NickODell 不,不幸的是它没有。
标签: python google-colaboratory