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

1、切换python

!sudo update-alternatives --config python3

输出如下,键入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  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

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

!python -V

2、安装pip

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

!sudo apt-get install python3-pip
!python -m pip install --upgrade pip

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

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

!pip install ipykernel

你可能感兴趣的:(计算机科学与技术,python,pip,tensorflow)