查看centos5.5默认python版本
[root@Django ~]# python
Python 2.4.3 (#1, Sep 3 2009, 15:37:12)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
下载python2.7.2
[root@Django ~]# wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
安装python2.7.2
[root@Django ~]# tar xvf Python-2.7.2.tgz
[root@Django ~]# cd Python-2.7.2
[root@Django Python-2.7.2]# ./configure
[root@Django Python-2.7.2]# make && make install
python2.7 默认安装在
/usr/local/lib/python2.7
查看安装的python2.7
[root@Django Python-2.7.2]# /usr/local/bin/python
Python 2.7.2 (default, Apr 5 2012, 14:37:00)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@Django Python-2.7.2]# /usr/local/bin/python -V
Python 2.7.2
这个时候系统默认的python还是
[root@Django Python-2.7.2]# python
Python 2.4.3 (#1, Sep 3 2009, 15:37:12)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
修改系统默认的python(为什么不删除默认的python呢,这是因为yum是基于2.4.3的)
[root@Django Python-2.7.2]# mv /usr/bin/python /usr/bin/python.bak
[root@Django Python-2.7.2]# ln -s /usr/local/bin/python2.7 /usr/bin/python
这个时候我们修改了系统默认的python 版本为2.7 但是yum 是基于2.4的,如果这个时候你使用yum服务是会出错的
恢复不能使用的yum yum-update
[root@Django Python-2.7.2]# vi /usr/bin/yum
[root@mysqlnode2 ~]# vim /usr/sbin/yum-updatesd
将首行显示的 !#/usr/bin/python 修改为 !#/usr/bin/python2.4
为了后续方便软件的安装,需要使用easy_install ,则需要安装Setuptools模块
下载
[root@Django ~]# wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea
安装
[root@Django ~]# sh setuptools-0.6c11-py2.7.egg
Processing setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to /usr/local/lib/python2.7/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin
Installed /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11