[英]Google Colab Python version not changing
I want to change the python version on my Google Colab.我想在我的 Google Colab 上更改 python 版本。 Currently, it's running python 3.7:
目前,它正在运行 python 3.7:
[In]: ! python --version
[Out]: Python 3.7.13
I want python 3.10, so I followed the instructions in this post :我想要 python 3.10,所以我按照这篇文章中的说明进行操作:
! 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
Here, a list is printed, and I choose python 3.10.这里打印了一个列表,我选择 python 3.10。 Then
然后
! sudo apt install python3-pip
Now, when I query the python version, it shows 3.10:现在,当我查询 python 版本时,它显示 3.10:
[In]: ! python --version
[Out]: Python 3.10.6
So far so good!到目前为止,一切都很好! BUT , now there are two problems:
但是,现在有两个问题:
!pip install gym
and !pip3 install gym
give the following error:!pip install gym
和!pip3 install gym
都会出现以下错误:AttributeError: module 'collections' has no attribute 'MutableMapping'
[In]: (a := 3)
[Out]: SyntaxError: invalid syntax
[In]: a: list[int] = [1]
[Out]: TypeError: 'type' object is not subscriptable
you must downgrade python.您必须降级 python。
Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module.
自 3.3 版起已弃用,将在 3.10 版中删除:将 Collections 抽象基类移至 collections.abc 模块。 For backwards compatibility, they continue to be visible in this module through Python 3.9.
为了向后兼容,它们通过 Python 3.9 在此模块中继续可见。
Ref.
参考。 https://docs.python.org/3.9/library/collections.html
https://docs.python.org/3.9/library/collections.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.