第一步:下载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. haskell笔记1

    haskell platform下载:https://www.haskell.org/platform/ 进入haskell控制台,终端输入 $ ghci 编译文件 :l file.hs 数组操作 & ...

  2. -XX:+PrintGCDetails 打印GC详细信息

    -XX:+PrintGCDetails –打印GC详细信息     n-XX:+PrintGCDetails的输出 –Heap – def new generation   total 13824K, ...

  3. ubuntu android环境配置

    1.下载eclipse 2.下载sdk 3.安装adt 4.配置sdk环境路径sudo gedit /etc/profile export PATH=$JAVA_HOME/bin:$JAVA_HOME ...

  4. Report launcher to run SSRS report subscriptions on demand

    http://www.mssqltips.com/sqlservertip/3078/report-launcher-to-run-ssrs-report-subscriptions-on-deman ...

  5. 图像处理之常用颜色RGB、灰度值

    128/0/0       深红         255/0/0       红           255/0/255     粉红        255/153/204 玫瑰红       153 ...

  6. OpenStack collectd的从零安装服务端

    安装collectd包操作同客户端相同,不在赘述 配置文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 ...

  7. 关于 ActiveMQ 的消息模式

    1.JMS Queue 执行 load balancer语义:一条消息仅能被一个 consumer(消费者) 收到.如果在 message 发送的时候没有可用的consumer,那么它将被保存一直到能 ...

  8. zabbix用自带模板监控mysql

    本身zabbix-agent没有提供对mysql监控的key,所以需要自定义key来应用这个模板 默认的模板有以下三类 mysql.status[var] mysql.ping mysql.versi ...

  9. android 下的技巧

    1.删除屏幕的手势锁定 adb shell #登录 su $切换到su用户(手机需要root) cd /data/system #切换目录 rv gesture.key # 删除锁屏文件,然后进去的时 ...

  10. Linux 编程中的API函数和系统调用的关系【转】

    转自:http://blog.chinaunix.net/uid-25968088-id-3426027.html 原文地址:Linux 编程中的API函数和系统调用的关系 作者:up哥小号 API: ...