Centos 6.4 python 2.6 升级到 2.7

 

 

查看python的版本

  1. #python  -V    
  2. Python 2.6.6  
#python  -V  
Python 2.6.6

1.下载Python-2.7.3
  1. #wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2  
#wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2

2.解压
  1. #tar -jxvf Python-2.7.3.tar.bz2  
#tar -jxvf Python-2.7.3.tar.bz2

3.更改工作目录
  1. #cd Python-2.7.3  
#cd Python-2.7.3

4.安装
  1. #./configure  
  2. #make all             
  3. #make install  
  4. #make clean  
  5. #make distclean  
#./configure
#make all           
#make install
#make clean
#make distclean

5.查看版本信息
  1. #/usr/local/bin/python2.7 -V  
#/usr/local/bin/python2.7 -V

6.建立软连接,使系统默认的 python指向 python2.7
  1. #mv /usr/bin/python /usr/bin/python2.6.6  
  2. #ln -s /usr/local/bin/python2.7 /usr/bin/python  
#mv /usr/bin/python /usr/bin/python2.6.6
#ln -s /usr/local/bin/python2.7 /usr/bin/python

7.重新检验Python 版本
  1. #python -V  
#python -V

8解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本
  1. #vi /usr/bin/yum  
#vi /usr/bin/yum
将文件头部的
#!/usr/bin/python


改成
#!/usr/bin/python2.6.6

pip 修改源

vi ~/.pip/pip.conf


[global]
index-url = http://pypi.v2ex.com/simple

原文地址:https://www.cnblogs.com/noobkey/p/3624934.html