zoukankan      html  css  js  c++  java
  • centos6.3升级python至2.7.5

    centos6.3自带的python版本是2.6.6,有时候需要升级到2.7。这里记录一下升级过程,方便查阅。实际上是转载自http://flyingdutchman.iteye.com/blog/1885564

    1.安装gcc。

    yum install gcc gcc-c++ 

    2.下载python-2.7.5.tar.xz。

    wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.xz

    3.解压安装

    xz -d Python-2.7.5.tar.xz //确保有xz工具,若没有则需先安装
    tar xvf Python-2.7.5.tar
    cd Python-2.7.5
    ./configure --prefix=/usr/local/python27
    make && make install 

    4.建立软连接,使系统默认的python指向python27 。

    mv /usr/bin/python /usr/bin/python2.6.6.old 
    ln -s /usr/local/python27/bin/python2.7 /usr/bin/python

    5.已经安装完成python的安装或升级的全部操作了,我们再来看一下现在的python的版本。#

    #python -V 
    Python 2.7.5 

    6.虽然现在python已经安装完成,但是使用yum命令会有问题——yum不能正常工作了。需要做一点小小的修改就可以了。

    [root@client1 ~]# yum list

    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:

    
    

    No module named yum

    
    

    Please install a package which provides this module, or
    verify that the module is installed correctly.

    
    

    It's possible that the above module doesn't match the
    current version of Python, which is:
    2.7.5 (default, Aug 1 2014, 16:49:01)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]

    
    

    If you cannot solve this problem yourself, please go to
    the yum faq at:
    http://yum.baseurl.org/wiki/Faq

     

      这是因为yum默认使用的python版本是2.6.6,而现在使用的python版本是2.7.5,故会出现上述问题,只需要该一下yum的默认python配置版本就行了:

    #vi /usr/bin/yum 
     //将文件头部的#!/usr/bin/python改为 
     #!/usr/bin/python2.6 

    8.升级完成!

  • 相关阅读:
    python-pyStrich条形码模块
    js原型及原型链解析
    解决Genymotion下载device时较慢的问题
    nodejs实现OAuth2.0授权服务
    Swagger文档添加file上传参数写法
    TypeScript学习笔记之类
    TypeScript学习笔记之接口类型
    win64环境下使用curl命令
    TypeScript学习笔记之基础类型
    WebRTC介绍及简单应用
  • 原文地址:https://www.cnblogs.com/zhutianpeng/p/3883511.html
Copyright © 2011-2022 走看看