当前位置:   article > 正文

【colab】python3.6的使用(两步,切换python version并安装pip)_google clab转换python版本

google clab转换python版本

1、切换python

!sudo update-alternatives --config python3
  • 1

输出如下,键入1则切换为3.6

There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8   2         auto mode
  1            /usr/bin/python3.6   1         manual mode
  2            /usr/bin/python3.8   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python3.6 to provide /usr/bin/python3 (python3) in manual mode
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

如果没有就强行安装,把3.8换成3.6即可,然后再去切换

!sudo apt-get update -y
!sudo apt-get install python3.8

!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2

!sudo apt-get install python3.8-distutils
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

此时用如下命令则能看到版本已经切换

!python -V
  • 1

2、安装pip

colab上的python3.6没有自带pip,用如下进行安装

!sudo apt-get install python3-pip
!python -m pip install --upgrade pip
  • 1
  • 2

此时便能成功安装tensorflow==1.15

不过运行程序时大概率你会发现你还需要安装如下

!pip install ipykernel
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/212055
推荐阅读
相关标签
  

闽ICP备14008679号