# 备份旧版本
mv /usr/bin/python /usr/bin/python_2.7.5
# 下载新版本
https://www.python.org/downloads/
https://www.python.org/downloads/release/python-2718/
wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
cd /home/soft
tar -xzf Python-2.7.18.tgz
cd Python-2.7.18
mkdir /usr/local/python2.7.18/
./configure --prefix=/usr/local/python2.7.18
make && make install
ln -s /usr/local/python2.7.18/bin/python2.7 /usr/bin/python
centos的python升级安装完成。
安装 pip
curl "https://bootstrap.pypa.io/pip/2.7/get-pip.py" -o "get-pip.py"
python get-pip.py
ln -s /usr/local/python2.7.18/bin/pip /usr/bin/pip
配置环境变量
vi /etc/profile
export PYTHON_HOME=/usr/local/python2.7.18
PATH=$PATH:$PYTHON_HOME/bin