Python3 与 Python2共存

  1. 查看当前python版本

                    
                      python --version
                    
                  
  2. 备份python

                    
                      which python
    mv /usr/bin/python /usr/bin/python.bak
                    
                  
  3. 下载安装更新python3

                    
                      wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
    tar -xvJf  Python-3.6.2.tar.xz
                    
                  
  4. 安装关联程序,安装编译python3

                    
                      yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
    cd Python-3.6.2
    ./configure prefix=/usr/local/python3
    make && make install
    ln -s /usr/local/python3/bin/python3 /usr/bin/python
                    
                  
  5. 查看python版本

                    
                      python --version
                    
                  
  6. 修改相关执行程序python版本

                    
                      vi /usr/bin/yum
    把#! /usr/bin/python修改为#! /usr/bin/python2
    vi /usr/libexec/urlgrabber-ext-down 
    文件里面的#! /usr/bin/python 也要修改为#! /usr/bin/python2