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*