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