升级 python 2.6.6 系统到 2.7.10 版本
来源:互联网 发布:淘宝ifashion怎么开通 编辑:程序博客网 时间:2024/05/16 12:01
CentOS 6 系统默认 Python 版本是:2.6.6 平时在使用中遇到很多的库要求是 2.7.x 版本的库,比如使用 ConfigParser 库,在 2.6 版本库就不支持没有 value 值的配置项,需要升级到 2.7 以上的库才行,这次就尝试升级一下 Python 到 2.7.x 版本,记录于此。
一、升级 Python 2.7.10 版本
1. 准备安装包,系统是最小化安装
# 下载安装依赖的相关包
[root@vip ~]# yum install vim gcc make wget -y[root@vip ~]# yum install openssl-devel zlib-devel readline-devel sqlite-devel -y
# 下载[root@vip ~]# cd /usr/local/src
[root@vip ~]# wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz# 解压[root@vip ~]# tar -zxvf Python-2.7.10.tgz[root@vip ~]# lsPython-2.7.10 Python-2.7.10.tgz
2. 编译配置安装
[root@vip ~]# cd Python-2.7.10[root@vip Python-2.7.10]# ./configure --enable-shared --enable-loadable-sqlite-extensions \ --prefix=/usr/local/python27 --with-zlib --with-ssl[root@vip Python-2.7.10]# vim ./Modules/Setup # 找到下边这一行内容,去掉注释#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz[root@vip Python-2.7.10]# make && make install
3. 查看 python 版本信息
[root@vip Python-2.7.10]# python -VPython 2.6.6# 版本依旧是 2.6.6
4. 用 python2.7 替换旧版本
[root@vip Python-2.7.10]# cd /usr/bin/[root@vip bin]# ls python* -l # 旧 python 版本信息-rwxr-xr-x. 2 root root 4864 2月 22 2013 pythonlrwxrwxrwx. 1 root root 6 10月 22 18:38 python2 -> python-rwxr-xr-x. 2 root root 4864 2月 22 2013 python2.6
[root@vip bin]# mv /usr/bin/python /usr/bin/python2.6.6[root@vip bin]# ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
[root@vip bin]# ls python* -llrwxrwxrwx. 1 root root 33 10月 23 00:01 python -> /usr/local/python27/bin/python2.7lrwxrwxrwx. 1 root root 6 10月 22 18:38 python2 -> python-rwxr-xr-x. 2 root root 4864 2月 22 2013 python2.6-rwxr-xr-x. 2 root root 4864 2月 22 2013 python2.6.6
5. 重新验证 Python 版本信息
[root@vip bin]# python -VPython 2.7.10
可以看到,系统识别的 python 版本已经是 python 2.7.10
执行 python -V 遇到的问题:
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory# 原因:linux系统默认没有把/usr/local/python27/lib路径加入动态库搜索路径
解决:
[root@vip ~]# vim /etc/ld.so.conf# 添加如下一行内容/usr/local/python27/lib[root@vip ~]# ldconfig # 使新添加的路径生效
二、解决 yum 兼容性问题
因为 yum 是不兼容 Python 2.7 的,所以 yum 不能正常工作,我们需要指定 yum 的 Python 为 2.6。
1. 升级 python 后 yum 出现的问题
[root@vip bin]# yum There was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was: No module named yum... ... ... ...
2. 编辑 yum 配置文件
[root@vip bin]# vim /usr/bin/yum#!/usr/bin/python# 第一行修改为 python2.6.6#!/usr/bin/python2.6.6
3. 验证 yum 问题解决
[root@vip bin]# yum repolistLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile... ... ... ...
三、升级 python 后,安装 pip 工具
1. 下载安装
[root@vip ~]# wget https://bootstrap.pypa.io/get-pip.py[root@vip ~]# python get-pip.py
2. 设置软连接
[root@vip ~]# ln -s /usr/local/python27/bin/pip2.7 /usr/bin/pip
四、安装 ipython
[root@vip ~]# pip install ipython==1.2.1[root@vip ~]# ln -s /usr/local/python27/bin/ipython /usr/bin/ipython
参考链接:
http://www.jianshu.com/p/7d7c5cf267f4
http://xitongjiagoushi.blog.51cto.com/9975742/1681983/
---------- 本文结束 ----------
阅读全文
0 0
- 升级 python 2.6.6 系统到 2.7.10 版本
- CentOS 6.3 64bit上升级系统默认Python 2.6.6到2.7.10版本
- 升级python 到2.7.6版本
- 升级Python到2.7版本
- python 2.6.6升级到python 2.7.x版本的方法
- python 2.6.6升级到python 2.7.x版本的方法
- Centos 升级Python到2.6或2.7版本
- CentOS python版本的升级 从2.6 到2.7
- python版本是2.6升级到2.7.3
- Centos 5.5升级Python到2.7版本
- CentOS升级Python到2.7版本
- CentOS升级Python到2.7版本
- CentOS6升级Python到2.7.3版本
- Centos 5.5升级Python到2.7版本
- 将CentOS系统默认的python手动升级最新到2.7.13版本
- 将CentOS系统默认的python一键自动升级到最新的2.7.13版本
- centos系统python版本升级
- CentOS 6升级python 2.6到2.7
- JavaWeb——文件上传和下载
- IAR 编译不过performing Post-Build Action的问题
- 并发编程1:全面认识 Thread
- Python Numpy的数组array和矩阵matrix
- Tp自定义分页
- 升级 python 2.6.6 系统到 2.7.10 版本
- 创建GitHub私有库,制作CocoaPods依赖库(史上最详细)
- UVA 439 跳马(国际象棋里的骑士)BFS
- wordpress 前英文后台中文
- Linux下的五个查找命令:grep、find、locate、whereis、which
- C语言结构体深度剖析
- springmvc执行流程非代码1
- Java常用排序
- Java中BIO,NIO,AIO