python-3.x - 为所有用户更改 python 和 python3 的默认版本

标签 python-3.x ubuntu

我工作的服务器(Ubuntu 18.3)安装了 python 2.7 和 3.6,我最近不得不为一个项目安装 3.8。不幸的是,这弄乱了默认版本,我无法修复它。
我得到了什么:

$ python2 --version
Python 2.7.17
$ python3 --version
Python 3.8.5
$ python --version
Python 3.6.9
我想要的是:
$ python2 --version
Python 2.7.17
$ python3 --version
Python 3.6.9
$ python --version
Python 2.7.17
我试过了:
$ 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.8   2         auto mode
* 1            /usr/bin/python3.6   1         manual mode
  2            /usr/bin/python3.8   2         manual mode

$ sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
我还在/usr/bin 中看到了 python3 的符号链接(symbolic link),但它看起来是正确的:
$ /usr/bin/python3 --version
Python 3.6.9
非常感谢你的帮助!

最佳答案

现在在 Ubuntu 20.04 LTS 默认的 python3 为 python 可以通过这个命令简单地设置:

$ sudo apt install python-is-python3
$ python --version
Python 3.8.5

关于python-3.x - 为所有用户更改 python 和 python3 的默认版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64196408/

相关文章:

python - 如何让python进程在后台持续运行

ubuntu - 发送 SNMP 陷阱的 Cacti 阈值

python - 我无法在 Ubuntu 14.04 中安装 Anaconda

python - 在n级列中逐行分类excel数据

c# - monoDevelop ubuntu c# Class List 没有 elementAt 方法

python - 无法使用 Scrapy dist-packages/cryptography/hazmat/bindings/_openssl.so 启动项目

c# - 请求特权并在 Ubuntu Linux 中使用 C# 保留此权限

python - 如何删除以用户选择的字母开头的所有项目?

python - 根据字符的出现对列表进行排序

安装了Python 3,运行时出错