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. jq:mouseover和mouseout多次触发解决办法

    区别: mouseover与mouseenter 不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件. 只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件. mou ...

  2. luogu1231 教辅的组成

    注意把书拆成两份 #include <iostream> #include <cstring> #include <cstdio> #include <que ...

  3. 练习题,新建数据库anyun

    一.新建数据库,数据库名为anyun mysql> create database anyun; Query OK, 1 row affected (0.00 sec) 二.查看数据库 mysq ...

  4. Java 正则表达式详解---https://www.jb51.net/article/16829.htm

    一.正则表达式基础知识 我们先从简单的开始.假设你要搜索一个包含字符“cat”的字符串,搜索用的正则表达式就是“cat”.如果搜索对大小写不敏感,单词“catalog”.“Catherine”.“so ...

  5. 【Android】SharedPreference存储数据

    SharedPreference存储数据 使用SharedPreference保存数据  putString(key,value) 使用SharedPreference读取数据  getString( ...

  6. Ubuntu 终端命令整理

    一.文件目录类 1.建立目录:mkdir 目录名 2.删除空目录:rmdir 目录名 3.无条件删除子目录: rm -rf 目录名 4.改变当前目录:cd 目录名 (进入用户home目录:cd ~:进 ...

  7. GTY's birthday gift【矩阵快速幂】

    题目大意:GTY的朋友ZZF的生日要来了,GTY问他的基友送什么礼物比较好,他的一个基友说送一个可重集吧!于是GTY找到了一个可重集S,GTY能使用神犇魔法k次,每次可以向可重集中加入一个数 a+b ...

  8. Snmp的学习总结(一)

    摘自:http://blog.csdn.net/shanzhizi/article/details/11606767   目录(?)[-] SNMP的5种协议数据单元 SNMP的运行过程 11 Get ...

  9. Tomcat 调优技巧

    Tomcat 调优技巧:1.Tomcat自身调优: ①采用动静分离节约Tomcat的性能: ②调整Tomcat的线程池: ③调整Tomcat的连接器: ④修改Tomcat的运行模式: ⑤禁用AJP连接 ...

  10. C++练习,计算间隔天数

    time_t time(time_t *time) 从1970年1月1日到到现在的秒数,如果系统时间不存在,返回1char *ctime(const time_t *time) 返回以:day mon ...