centos6.4默认安装的是python 2.6.6,现在要升级python升级到2.7.x,到官网下载最新版本,我下载时最新版本是2.7.11,地址如下:https://www.python.org/downloads/release/python-2711/
yum install readline-devel -y #安装这个包是为了解决python交互模式使用键盘上的方向键乱码的问题
tar -xzvf Python-2.7.11.tgz
cd Python-2.7.11
./configure --prefix=/usr/local/python2.7.11
make
make install
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/pyton2.7.11/bin/pyton /usr/bin/python #修改默认的python版本
#安装easy_install
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
#安装pip
east_install pip
#我之前已安装过pip和easy_install,将新安装的pip和easy_install软链接一下
mv /usr/bin/easy_install /usr/bin/easy_install2.6.6
ln -s /usr/local/python2.7.11/bin/easy_install /usr/bin/easy_install
mv /usr/bin/pip /usr/bin/pip2.6.6
ln -s /usr/local/python2.7.11/bin/pip /usr/bin/pip
sed -i 's/python/python2.6.6/g' /usr/bin/yum #修改yum使用的python版本