1、下載源碼
wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
2、解壓
tar zxvf Python-2.7.11.tgz
3、安裝
cd Python-2.7.11
./configure --prefix=/usr/local/python27
make && make install
4、修改系統默認python,並更新
mv /usr/bin/python /usr/bin/python2.6.old
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
5、檢測
python -V,顯示2.7.11
6、更改yum解釋器
由於yum使用python解釋器,輸入命令yum list,顯示
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python
vi /usr/bin/yum
將文件頭部的#!/usr/bin/python改爲#!/usr/bin/python2.6