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