CentOS 8 默認情況下不安裝任何 版本的 Python
, 需要管理員自己安裝
- Python 3.6 是 CentOS 8中的默認Python
- Python 2.7 實現有限支持。
如果有多個版本,如何設定 默認版本? 可以使用alternatives
控制默認版本
參考: update-alternatives 管理軟件版本
[root@aikaiyuan ~]# dnf install python2 python3 -y [root@aikaiyuan ~]# python2 -V Python 2.7.15 [root@aikaiyuan ~]# python3 -V Python 3.6.8 [root@aikaiyuan ~]# python -V -bash: /usr/bin/python: No such file or directory [root@aikaiyuan ~]#
Python 3 默認
[root@aikaiyuan ~]# alternatives --set python /usr/bin/python3 [root@aikaiyuan ~]# python -V Python 3.6.8
Python 2 默認
[root@aikaiyuan ~]# alternatives --set python /usr/bin/python2 [root@aikaiyuan ~]# python -V Python 2.7.15