将linux默认python升级到2.7.4版本
2015-08-29 10:30
519 查看
转:http://blog.sina.com.cn/s/blog_7d31bbee0101lzh9.html 非常感谢!第一步:下载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[root@localhost ~]# cp /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变更后的名字)
[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[root@localhost ~]# cp /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学习笔记----进程管理----杀死进程and 把进程放入后台
- Linux字符设备驱动程序编译进入内核的方法
- linux命令(2):gzip命令
- linux命令(1):wget命令
- 玩转linux第四天之用户及组管理类相关命令(二)
- passwd修改用户密码
- 玩转linux第四天之用户及组管理概念(一)
- Linux学习笔记-----进程管理-查看系统健康状态
- 有趣的 Linux 命令
- 实用的Linux find命令示例
- linux 下 gdb 调试
- Linux 开发常用命令
- linux中Find命令的使用
- linux 下结合find 和 rm 删除大量文件
- Linux的inode的理解
- Linux_2day------------搭建mysql服务器
- Linux下出现 error: mysql.h: No such file or directory 的解决办法
- Linux 命令学习之apt命令详解
- /sys目录下各个子目录的具体说明
- Linux驱动模型之class结构解析