1. 下載python2.7.5,保存到 /data/qtongmon/software
http://www.python.org/ftp/python/
2. 解壓文件
tar xvf Python-2.7.5.tar.bz2
3. 建立安裝目錄
mkdir /usr/local/python27
4. 安裝python
cd Python-2.7.5
./configure --prefix=/usr/local/python27
make
make install
5. 修改老版本的ln指向(注意:這裏修改後,可能會影響yum的使用)
mv /usr/bin/python /usr/bin/python2.4.3
ln -s /usr/local/python27/bin/python /usr/bin/python
6.yum是使用python寫的,升級新版本的python後會致使yum不可用,以下爲運行yum時的錯誤提示:
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
解決方法:
查找yum文件,並編輯此py文件
[root@TC-Boss ~]# which yum
/usr/bin/yum
[root@TC-Boss ~]# vi /usr/bin/yum
將
#!/usr/bin/python
改成:
whereis python出來的結果(老版本的python)
#!/usr/bin/python2.6
而後保存OK.
附:
yum源配置文件
vim /etc/yum.repos.d/rhel-debuginfo.repo
yum安裝
yum install -y python*
yum update -y python*
yum search -y python*