CentOS升级Python

  1. Python升级参考

  2. 安装前的准备

     yum install gcc-c++ -y
    
  3. 浏览器打开python官网源码库

     https://www.python.org/ftp/python/
    
  4. 选择你想要安装的python版本(以3.7.2为例)

     https://www.python.org/ftp/python/3.7.2/
    
  5. 找到Python-3.7.2.tar.xz,复制下载链接,下载

     wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
    
  6. 解压安装包

     tar -xvf Python-3.7.2.tar.xz
    
  7. 进入目录Python-3.7.2

     cd Python-3.7.2
    
  8. 安装python

     ./configure --prefix=/usr/local/python
     make
     make install
    
  9. 移动旧版python

     mv /usr/bin/python /usr/bin/python_old
    
  10. 修改yum的解释程序为python_old

     vim /usr/bin/yum
    
     #!/usr/bin/python
     # 改为
     #!/usr/bin/python_old
    
     ESC
     :wq
    
  11. 测试yum是否正常可用

     yum --help
    
  12. 为新安装的python设置软连接到环境变量可及的目录

     ln -s /usr/local/python/bin/python3.7 /usr/bin/python
    
  13. 测试升级是否成功

     python -V
     python --version
    

results matching ""

    No results matching ""