CentOS6.5 python 2.6升级到2.7

  1. 下载python2.7.3包,并解压缩,输入命令:
    #wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
    #tar -jxvf Python-2.7.3.tar.bz2

  2. 进入python2.7.3目录进行安装,输入命令:
    #cd Python-2.7.3
    #./configure 

    root@MiWiFi-R1CM Python-2.7.3]# ./configure
    checking for --enable-universalsdk... no
    checking for --with-universal-archs... 32-bit
    checking MACHDEP... linux2
    checking EXTRAPLATDIR...
    checking machine type as reported by uname -m... x86_64
    checking for --without-gcc... no
    checking for gcc... no
    checking for cc... no
    checking for cl.exe... no
    configure: error: in `/root/Python-2.7.3':
    configure: error: no acceptable C compiler found in $PATH
    See `config.log' for more details

    通过查看,linux未安装gcc环境

    #yum install gcc
    #make all            
    #make install 
    #make clean 
    #make distclean

  3. 建立软连接,使系统默认的 python指向 python2.7,输入命令:
    #mv /usr/bin/python /usr/bin/python2.6.6
    #ln -s /usr/local/bin/python2.7 /usr/bin/python

  4. 查看版本信息,输入命令:#python -V

  5.  Python 软链接指向 Python2.7后,因为yum不兼容 Python 2.7,所以yum不能正常工作,需要指定 yum 的Python版本,输入命令:
    #vi /usr/bin/yum
    将文件头部改为:
    #!/usr/bin/python2.6.6

 

你可能感兴趣的:(CentOS6.5 python 2.6升级到2.7)