第一步:下载python2.7.4版本源码:

wget http://python.org/ftp/python/2.7.4/Python-2.7.4.tgz

解压文件

[aa@localhost ~]$ tar jxvf Python-2.7.4.tar.bz2

[niuxl@localhost ~]$ cd Python-2.7.4
[niuxl@localhost Python-2.7.4]$ ls
config.guess 
configure    
Demo  Grammar 
install-sh  LICENSE 
Makefile.pre.in  Modules 
Parser 
PCbuild       
Python 
RISCOS   
Tools
config.sub   
configure.ac 
Doc   Include 
Lib        
Mac     
Misc            
Objects 
PC     
pyconfig.h.in  README 
setup.py
[niuxl@localhost Python-2.7.4]$ su -
口令:
[root@localhost ~]# mkdir /usr/local/python2.7.4
[root@localhost ~]# cd /home/
[root@localhost home]# cd niuxl/Python-2.7.4
[root@localhost Python-2.7.4]# ls
config.guess 
configure    
Demo  Grammar 
install-sh  LICENSE 
Makefile.pre.in  Modules 
Parser 
PCbuild       
Python 
RISCOS   
Tools
config.sub   
configure.ac 
Doc   Include 
Lib        
Mac     
Misc            
Objects 
PC     
pyconfig.h.in  README 
setup.py

编译之前,需要先安装zlib包:

[root@localhost Python-2.7.4]# yum install zlib zlib-devel
[root@localhost Python-2.7.4]# ./configure
--prefix=/usr/local/python2.7.4
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/niuxl/Python-2.7.4':
configure: error: no acceptable C compiler found in $PATH

缺少c编辑器

安装c编辑器:

[root@localhost Python-2.7.4]# yum install gcc

..略

注:有一个选择y和n的地方,提示是否继续下载,输入y,回车即可!

gcc安装完成

继续编译python

[root@localhost Python-2.7.4]# ./configure
--prefix=/usr/local/python2.7.4

..(略)

ok编译成功

[root@localhost Python-2.7.4]# make
&& make install

安装成功

[root@localhost Python-2.7.4]# python -V
Python 2.4.3

目前版本依然是2.4.3,现在开始升级python,

查看python命令所在目录

[root@localhost Python-2.7.4]# whereis python
python: /usr/bin/python2.4 /usr/bin/python /usr/lib/python2.4
/usr/include/python2.4 /usr/share/man/man1/python.1.gz

将/usr/bin/python 的软连接修改为python2.4.3

[root@localhost Python-2.7.4]# mv /usr/bin/python
/usr/bin/python2.4.3

[root@localhost Python-2.7.4]# python
-bash: /usr/bin/python: 没有那个文件或目录

python命令找不到,这时只需要将版本python2.7.4命令加入环境变量即可!

方式1:

修改/etc/profile加入如下两行:

PATH=$PATH:/usr/local/python2.7.4/bin
export PATH

然后

[root@localhost Python-2.7.4]# source /etc/profile

[root@localhost Python-2.7.4]# python -V
Python 2.7.4

当然也可以创建2.7.4版本的python的软连接:/usr/bin/python

[root@localhost ~]# ln -s /usr/local/python2.7.4/bin/python
/usr/bin/python

亦可

ok,python升级完成

到现在为止,还有最后一件事需要做,那就是yum与python的兼容问题:

[root@localhost pipe]# vi /usr/bin/yum

#!/usr/bin/python

第一行修改为

#!/usr/bin/python2.4.3(即原始的python变更后的名字)

将linux默认python升级到2.7.4版本的更多相关文章

  1. centos7里默认python升级到2.7.11

    CentOS镜像使用帮助 http://mirrors.163.com/.help/centos.html   安装gcc yum install gcc* openssl openssl-devel ...

  2. Linux下python升级到python-2.7.13

    下载python最新版本2.7.13并编译安装 wget https://www.python.org/ftp/python/2.7.12/Python-2.7.13.tar.xz xz -d Pyt ...

  3. Linux下python升级步骤

    先安装openssl,openssl-devel yum install openssl yum install openssl-devel 1切换到指定的目录下: cd /usr/local 2下载 ...

  4. Linux下python升级

    Centos即使用Yum更新也是Python2.6.6所以需要升级到Python2.7.8 1.先下载源码包 1 wget https://www.python.org/ftp/python/2.7. ...

  5. linux系统 python升级创建虚拟环境

    Python3.3以上的版本通过venv模块原生支持虚拟环境,可以代替之前的virtualenv. 该venv模块提供了创建轻量级“虚拟环境”,提供与系统Python的隔离支持.每一个虚拟环境都有其自 ...

  6. Linux下python安装升级详细步骤 | Python2 升级 Python3

    Linux下python升级步骤  Python2 ->Python3 多数情况下,系统自动的Python版本是2.x 或者yum直接安装的也是2.x 但是,现在多数情况下建议使用3.x 那么如 ...

  7. Linux下python安装升级详细步骤 | Python2 升级 Python3 转载

    Linux下python升级步骤  Python2 ->Python3 多数情况下,系统自动的Python版本是2.x 或者yum直接安装的也是2.x 但是,现在多数情况下建议使用3.x 那么如 ...

  8. linux 安装python,pip,

    Linux下python升级步骤 http://www.cnblogs.com/lanxuezaipiao/archive/2012/10/21/2732864.html 在 https://www. ...

  9. linux python2.x 升级python3.x

    Linux下python升级步骤  Python2 ->Python3 多数情况下,系统自动的Python版本是2.x 或者yum直接安装的也是2.x 但是,现在多数情况下建议使用3.x 那么如 ...

随机推荐

  1. paper 50 :人脸识别简史与近期进展

    自动人脸识别的经典流程分为三个步骤:人脸检测.面部特征点定位(又称Face Alignment人脸对齐).特征提取与分类器设计.一般而言,狭义的人脸识别指的是"特征提取+分类器"两 ...

  2. eclipse的debug模式启动缓慢

      这个问题可能是由于eclipse和服务器的交互而产生的,在以debug模式启动服务器时,发生了读取文件错误,eclipse自动设置了断点,导致服务器不能正常启动. 解决方法如下:以debug模式启 ...

  3. logstash学习2

    从geoip字段取location的longitude字段 [geoip][location][0] 支持变量内插 "the longitude is %{[geoip][location] ...

  4. RMAN基础知识补充

    一.FORMAT字符串替代变量 使用FORMAT参数时可使用的各种替换变量,如下: %c :备份片的拷贝数(从1开始编号): %d :数据库名称: %D :位于该月中的天数 (DD): %M :位于该 ...

  5. sdf

    SDF(Standard Delay Format)是一种存储timing data的文件,其中的数据是tool-independent的 可以包括: 1)Delay: module path, de ...

  6. 如何在真机上调试Android应用程序(图文详解)(zz)

    http://www.cnblogs.com/lanxuezaipiao/archive/2013/03/11/2953564.html   1.首先将手机设置为调试模式 方法:设置——应用程序——开 ...

  7. jquery ui和jquery easy ui的区别

    jquery ui 是jquery开发团队 开发,适用于网站式的页面.jquery easyui 是第三方基于jquery开发,适用于应用程序式的页面. 两者的方法调用也略有不同:jquery ui ...

  8. 机器学习实战5:k-means聚类:二分k均值聚类+地理位置聚簇实例

    k-均值聚类是非监督学习的一种,输入必须指定聚簇中心个数k.k均值是基于相似度的聚类,为没有标签的一簇实例分为一类. 一 经典的k-均值聚类 思路: 1 随机创建k个质心(k必须指定,二维的很容易确定 ...

  9. Index Condition Pushdown Optimization

    Index Condition Pushdown (ICP) is an optimization for the case where MySQL retrieves rows from a tab ...

  10. CC2541的任务与事件,以及红外捕捉.

    因为红外遥控要占用的系统中断时间可能超过了80ms, 极有可能导致蓝牙断线, 特别是连续两次按键, 100%断线. 后来根据蓝牙技术群里的哥们提示, 觉得不能在一个中断中delay得太久, 只能用任务 ...