Centos 6.5 python 2.6.6 升级到 2.7

1、查看python的版本

[root@localhost ~]# python -V
Python 2.6.6

2、安装python 2.7.3

    [root@localhost ~]# yum install -y gcc-c++

    [root@localhost ~]# wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.b

    [root@localhost ~]# tar -jxvf Python-2.7.3.tar.bz2

    [root@localhost ~]# cd Python-2.7.3

    [root@localhost Python-2.7.3]# ./configure

    [root@localhost Python-2.7.3]# make all

    [root@localhost Python-2.7.3]# make install

    [root@localhost Python-2.7.3]# make clean

  [root@localhost Python-2.7.3]# make distclean

3.查看版本信息  

[root@localhost ~]# /usr/local/bin/python2.7 -V 
Python 2.7.3

4、建立软连接,使系统默认的 python指向 python2.7

[root@localhost ~]# mv /usr/bin/python /usr/bin/python2.6.6 
[root@localhost ~]# ln -s /usr/local/bin/python2.7 /usr/bin/python

5、重新检验Python 版本 

[root@localhost ~]# python -V
Python 2.7.3

  

6、解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本 

   [root@localhost ~]# vi /ust/bin/yum

    将文件头部的 #!/usr/bin/python 

    改成 #!/usr/bin/python2.6.6

原文地址:https://www.cnblogs.com/yezl/p/6697965.html