Centos8 安裝Python



安裝python

  1. 更新系統軟件包

    [root@centos ~] dnf update -y
    
  2. 安裝python

    python 2的安裝

    [root@centos ~] dnf install python2 -y
    

    python 3的安裝

    [root@centos ~] dnf install python3 -y
    
  3. 驗證 python 的安裝

    python 2 的驗證

    [root@centos ~] python2 --version
    Python 2.7.17
    

    python 3的驗證

    [root@centos ~] python3 --version
    Python 3.8.0
    

設置系統默認python版本

  1. 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
    
  2. 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/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM