查看python的版本
view source
1 python -V
Python 2.4.3
1.先安装GCC
view source
1 yum -y install gcc
2.下载Python-2.7.2
view source
1 wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
3.解压Python-2.7.2
view source
1 tar -jxvf Python-2.7.2.tar.bz2
4.进入刚解压后的文件夹(可使用命令):
view source
1 cd Python-2.7.2
5.安装
view source
1 ./configure
2 make all
3 make install
4 make clean
5 make distclean
6.查看版本信息
view source
1 /usr/local/bin/python2.7 -V
7.建立软连接,使系统默认的python指向python2.7
正常情况下即使python2.7安装成功后,系统默认指向的python仍然是2.4.3版本,考虑到yum是基于python2.4.3才能正常工作,不敢轻易卸载。
如何实现将系统默认的python指向到2.7版本呢?
view source
1 mv /usr/bin/python /usr/bin/python2.4
2 ln -s /usr/local/bin/python2.7 /usr/bin/python
检验python指向是否成功
view source
1 python -V
8.解决系统python软链接指向python2.7版本后,yum不能正常工作
view source
1 vi /usr/bin/yum
将文件头部的
view source
print ?
1 #!/usr/bin/python
改成
view source
print ?
1 #!/usr/bin/python2.4