[root@junper ~]# dnf install python2 python3 -y
[root@junper ~]# python2 -V
Python 2.7.15
[root@junper ~]# python3 -V
Python 3.6.8
[root@junper ~]# python -V
-bash: /usr/bin/python: No such file or directory
[root@junper ~]#

Python 3 默认

[root@junper ~]# alternatives --set python /usr/bin/python3
[root@junper ~]# python -V
Python 3.6.8

Python 2 默认

[root@junper ~]# alternatives --set python /usr/bin/python2
[root@junper ~]# python -V
Python 2.7.15

另外一种方案

update-alternatives --install /usr/bin/python python /usr/bin/python2 100

update-alternatives --install /usr/bin/python python /usr/bin/python3 150

京东云 CentOS 设置Python 默认版本_Python