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. seajs模块化加载框架使用

    seajs是模块化加载框架.seajs.org已经打不开了,seajs的github.seajs速查文档 <!--如果完成下面4步,则seajs掌握了80%js模块化1.引入seajs的库 :& ...

  2. Java-在JVM关闭前调用的函数

    参考:http://qtlkw.iteye.com/blog/1018872 package com.tj; import java.text.SimpleDateFormat; import jav ...

  3. Decorator(装饰器模式)

    装饰器模式允许我们根据运行时不同的情景动态地为某个对象调用前后添加不同的行为动作. <?php class HtmlTemplate { // any parent class methods ...

  4. 使用Unity做2.5D游戏教程(一)

    最近在研究Unity 3D,看了老外Marin Todorov写的教程很详细,就翻译过来以便自己参考,翻译不好的地方请多包涵. 如果你不了解2.5D游戏是什么,它基本上是个3D游戏而你可以想象是压扁的 ...

  5. 洛谷P2522 - [HAOI2011]Problem b

    Portal Description 进行\(T(T\leq10^5)\)次询问,每次给出\(x_1,x_2,y_1,y_2\)和\(d\)(均不超过\(10^5\)),求\(\sum_{i=x_1} ...

  6. 「SDOI2010」古代猪文(bzoj1951)

    题目写了一大堆背景. 一句话题意就是求 $q^{\sum_{d|n}C_{n}^{d}} \mod 999911659$. 因为$n$是质数,只有当$q$是$n$的倍数时(此题数据范围原因,最多$q= ...

  7. 【2018.10.10】[HNOI2008] GT考试(bzoj1009)

    10pts: 暴力枚举字符串,Hash判是否出现.(真会有人写么) 时间复杂度$O(10^n*n)$. 40pts: 学过OI的人都会写的dp 如果这道题的40pts($n\le 250000$)设成 ...

  8. 关于EOF,转自新浪微博

    本文转自http://blog.sina.com.cn/s/blog_7714171f0101798y.html EOF 是 End Of File 的缩写. 在C语言中,它是在标准库中定义的一个宏. ...

  9. 更改navigationBar 颜色

    
 
 if (IS_IOS7()) { /* iOS7 时 Navigation 颜色 */ [[UINavigationBar appearance] setBarTintColor: HexCo ...

  10. cannot find package "golang.org/x/crypto/pbkdf2" in any of:

    cannot find package "golang.org/x/crypto/pbkdf2" in any of: /Users/zhou/go/src/mos.market/ ...