centos6更新python2.7

来源:互联网 发布:波士顿矩阵问题类例子 编辑:程序博客网 时间:2024/05/17 02:55
centos6更新python

更新系统

yum -y update


安装 python 工具需要的额外软件包

yum groupinstall -y 'development tools'
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget

安装readline-devel防止python在shell下按键乱码 

yum install -y readline-devel


源码安装Python 2.7.x 版本自己选择
wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
xz -d Python-2.7.8.tar.xz
tar -xvf Python-2.7.8.tar

安装详情:
# 进入目录:
cd Python-2.7.8
# 运行配置 configure:
./configure --prefix=/usr/local
# 编译安装:
make
make install

path设置:
1、先把之前的python软连接重命名 mv /usr/bin/python /usr/bin/python2.6.X
2、建立软连接 ln -s /usr/local/bin/python2.7  /usr/bin/python

yum只支持python2.6,修改yum配置
vim /usr/bin/yum
将#!/usr/bin/python改为 #!/usr/bin/python2.6.X


注意:有些需要使用yum安装的python模块安装后只能在python2.6中使用,要在2.7中使用要用源码安装
0 0
原创粉丝点击