安裝python
-
更新系統軟件包
[root@centos ~] dnf update -y
-
安裝python
python 2的安裝
[root@centos ~] dnf install python2 -y
python 3的安裝
[root@centos ~] dnf install python3 -y
-
驗證 python 的安裝
python 2 的驗證
[root@centos ~] python2 --version Python 2.7.17
python 3的驗證
[root@centos ~] python3 --version Python 3.8.0
設置系統默認python版本
-
python 2 默認
[root@centos ~] whereis python2 python2: /usr/bin/python2 /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 ... [root@centos ~] alternatives --set python /usr/bin/python2 [root@centos ~] python --version Python 2.7.17
-
python 3 默認
[root@centos ~] whereis python3 python3: /usr/bin/python3.8 /usr/bin/python3.6 ... [root@centos ~] alternatives --set python /usr/bin/python3 [root@centos ~] python --version Python 3.6.8
參考:
[1]:https://www.liquidweb.com/kb/how-to-install-python-on-centos-8/