一、查看系统信息
[root@localhost ~]# cat /etc/redhat-release CentOS release 6.4 (Final) [root@localhost ~]# uname -r 2.6.32-358.el6.x86_64
二、查看已安装python版本
[root@localhost ~]# rpm -qa|grep python python-2.6.6-36.el6.x86_64 libxml2-python-2.7.6-8.el6_3.4.x86_64 python-urlgrabber-3.9.1-8.el6.noarch python-iwlib-0.1-1.2.el6.x86_64 python-libs-2.6.6-36.el6.x86_64 rpm-python-4.8.0-32.el6.x86_64 dbus-python-0.83.0-6.1.el6.x86_64 python-iniparse-0.3.1-2.1.el6.noarch python-pycurl-7.19.0-8.el6.x86_64 libproxy-python-0.3.0-3.el6_3.x86_64 libreport-python-2.0.9-15.el6.centos.x86_64 newt-python-0.52.11-3.el6.x86_64 python-ethtool-0.6-3.el6.x86_64 abrt-addon-python-2.0.8-15.el6.centos.x86_64 [root@localhost ~]# python -V Python 2.6.6
三、下载编译安装python2.7.5版本源码包
[root@localhost ~]# cd /usr/local/src [root@localhost ~]# wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz [root@localhost ~]# tar xvf Python-2.7.5.tgz [root@localhost ~]# cd Python-2.7.5 [root@localhost ~]# ./configure [root@localhost ~]# make all [root@localhost ~]# make install [root@localhost ~]# make clean [root@localhost ~]# make distclean
四、将系统默认的python版本设置为2.7.5
[root@localhost ~]# rm /usr/bin/python [root@localhost ~]# ln -s /usr/local/bin/python2.7 /usr/bin/python
五、检查升级后的python版本
[root@localhost ~]# python -V Python 2.7.5
(转)https://blog.csdn.net/wailaizhu/article/details/54612982