linux升级python到2.7

一、下载python2.7安装包

# wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz

二、解压

# tar -zxf Python-2.7.12.tgz
# cd Python-2.7.12

三、新建安装目录,防止覆盖旧版本

# mkdir /usr/local/python27

四、安装

# cd Python-2.7.12
# ./configure --prefix=/usr/local/python27
# make && make install

五、旧版python改名

# mv /usr/bin/python /usr/bin/python24

六、创建链接到新版本

# ln -s /usr/local/python27/bin/python2.7 /usr/bin/python

七、测试

# python
Python 2.7.12 (default, Sep  2 2016, 09:17:20) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>