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.

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.

8.升级完成!

centos6.3升级python至2.7.5的更多相关文章

  1. centos6.5升级python为2.7

    今天线上服务器全部升级python环境为python-2.7.6的环境,我采用的方法是ansible+shell,代码如下,友提,Python-2.7.6.tgz.setuptools-14.3.1. ...

  2. CentOS6.5 升级 Python 2.7 版本

    转载请注明出处http://write.blog.csdn.net/mdeditor 目录 目录 前言 安装Python-279 解决YUM与Python279的兼容问题 前言 CentOS 6.5中 ...

  3. CentOS6.3升级Python到2.7.3版本

    http://www.zhangchun.org/the-centos6-3-upgrade-python-to-2-7-3-version/ 查看python的版本 1 python  -V  2 ...

  4. centos6.5 升级python 到 python 2.7.11 安装 pip

    1.首先官方下载源码,然后安装(./configure,make all,make install,make clean,make distclean) 注意:需要先安装zlib-devel,open ...

  5. Centos6.6升级python版本

    centos原生python为2.6.6,可以通过下面的命令查看 #python -V Python 注:在安装新版本前,请先安装zlib\openssl组件,如果你确认你用不到这个,也可以不装 需要 ...

  6. 大数据项目之_15_帮助文档_NTP 配置时间服务器+Linux 集群服务群起脚本+CentOS6.8 升级到 python 到 2.7

    一.NTP 配置时间服务器1.1.检查当前系统时区1.2.同步时间1.3.检查软件包1.4.修改 ntp 配置文件1.5.重启 ntp 服务1.6.设置定时同步任务二.Linux 集群服务群起脚本2. ...

  7. CentOS6 系统下升级python后yum命令使用时报错

    CentOS6 系统下升级python后yum命令使用时报错,如下: [root@xxxxxxx]#yumFile"/usr/bin/yum",line30exceptKeyboa ...

  8. VPS 的 CentOS6 升级 Python 的方法

    VPS 的 CentOS6 升级 Python 的方法 centos默认安装python2.6.由于python和centos关联紧密,所以不建议卸载,进行编译升级 1.新开的VPS务必系统更新 yu ...

  9. centos6升级python

    CentOS 6中,默认安装了Python 2.6.而pip,jupyter这样的常用工具是不支持Python 2.6的.为了使用这些工具,就必须将Python 2.6升级到Python 2.7以上的 ...

随机推荐

  1. shell脚本举例

    1.有时在写一些以循环方式运行的监控脚本,设置时间间隔是必不可少的,下面是一个Shell进度条的脚本演示在脚本中生成延时. #!/bin/bash b='' for ((i=0;$i<=100; ...

  2. CMDB资源配置管理项目

    浅谈ITIL TIL即IT基础架构库(Information Technology Infrastructure Library, ITIL,信息技术基础架构库)由英国政府部门CCTA(Central ...

  3. PYDay3-初识python

    Python 种类 c.j.iron.ruby等,主要有三类:cpython.xxxpython.pypy 种类繁多我们精通一种即可 编译流程: py代码->字节码->机器码->计算 ...

  4. Python第三方库之openpyxl(9)

    Python第三方库之openpyxl(9) 油炸圈饼图 甜甜圈图表与饼图相似,只是他们用的是环而不是圆.他们还可以将几个系列的数据绘制成同心环 from openpyxl import Workbo ...

  5. hdu2084

    老题目了 #include <stdio.h> int main(){ ][]; int i,j,max; int c,n; scanf("%d",&c); w ...

  6. ajax 原生 post

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. Scala基础知识[一]

    摘要:在Scala 是 Scalable Language 的简写,是一门多范式(multi-paradigm)的编程语言.设计初衷是要集成面向对象编程和函数式编程的各种特性.Scala 运行在Jav ...

  8. BZOJ 1974 [Sdoi2010]auction 代码拍卖会 ——动态规划

    把每一位上不递减的数拆成1+11+11111+11111+..... 然后就可以把巨大的N从复杂度中消掉,因为随着长度的增加1...111%p出现了循环节. 然后就是从n个数中选出几个使他们结果为0( ...

  9. 做运动(Dijkstra+并查集+MST)

    上面的题解是这样,这道题我真的脑残,其实打代码的时候就意识到了许多,可以用Dfs+Dij+二分,这样还可以卡一卡 但是我打了spfa+spfa+二分,这个显然很慢,类似的题目我好像还做过一道的,就是在 ...

  10. out.print和out.write

    这是一个JSP页面: <%@ page language="java" import="java.util.*"  %> <%@ page p ...