检查Ubuntu系统上有哪些Python版本:
$ ls /usr/bin/python* /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.7 /usr/bin/python3.7m /usr/bin/python3.8 /usr/bin/python3-futurize /usr/bin/python3m /usr/bin/python3-pasteurize
检查我们是否已配置一些Python备选方案。
sudo update-alternatives --list python update-alternatives: error: no alternatives for python
我们将设置两个Python替代方案:Python2和Python3替代方案:
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1 $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
再次查看Python备选方案。
$ sudo update-alternatives --list python /usr/bin/python2 /usr/bin/python3
切换到备用Python版本:
$ sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ----------------------------------------------------------- * 0 /usr/bin/python3 2 auto mode 1 /usr/bin/python2 1 bananaal mode 2 /usr/bin/python3 2 bananaal mode Press to keep the current choice[*], or type selection number: 1
检查新的Python版本:
$ python -V Python 2.7.17
日期:2020-07-07 20:55:53 来源:oir作者:oir