1.安裝開發工具包
yum groupinstall "Development tools"
2.安裝編譯Python需要的元件
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
3.下載並解壓最新Python 2.7的原始碼
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
tar xf Python-2.7.10.tar.xz
4.編譯與安裝Python
cd Python-2.7.10
./configure --prefix=/usr/local
make && make install
make clean
make distclean
5.將系統python命令指向Python 2.7
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
6.將yum需要執行的python指定為2.6.6
vi /usr/bin/yum
將檔案頭部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6