CentOS环境 升级Python2.6.6至2.7.5

 

 

1.查看当前Python版本

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

Python 2.6.6

 

2.下载Python2.7.5源码

 

 
  1. # wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz 
# wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz
3.解压源代码包

 

 

 
  1. # tar xvf Python-2.7.5.tgz 
# tar xvf Python-2.7.5.tgz
4.进入解压目录并安装

 

 

 
  1. # cd Python-2.7.5 
  2. # ./configure 
  3. # make all 
  4. # make install 
  5. # make clean 
  6. # make distclean 
# cd Python-2.7.5

# ./configure

# make all

# make install

# make clean

# make distclean

 

5.将系统默认的python设置为python2.7.5

 

 
  1. # rm /usr/bin/python 
  2. # ln -s /usr/local/bin/python2.7 /usr/bin/python 
# rm /usr/bin/python

# ln -s /usr/local/bin/python2.7 /usr/bin/python

 

6.检查Python版本

 

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

Python 2.7.5

 

7.解决yum不能运行的问题

因为yum是依赖python2.6.6运行的,所以需要对yum做一些修改

 

 
  1. # vim /usr/bin/yum 
# vim /usr/bin/yum

 

将第一行的#!/usr/bin/python修改为#!/usr/bin/python2.6

你可能感兴趣的:(python)