centos6.5升级python为2.7

今天线上服务器全部升级python环境为python-2.7.6的环境,我采用的方法是ansible+shell,代码如下,友提,Python-2.7.6.tgz、setuptools-14.3.1.tar.gz、pip-9.0.1.tar.gz,这三个包我是提前下好放在/data/x5online/tools目录下,当然你也可以直接在脚本中wget相关包,个人喜欢把包下好了然后统一放在/data/x5online/tools目录里,脚本比较简单,记录下,省的又忘了,节约时间。时间就是金钱啊

#!/bin/bash

yum install python-devel zlib-devel -y

cd /data/x5online/tools

tar xf Python-2.7.6.tgz

cd Python-2.7.6
echo "开始编译python"
./configure --prefix=/usr/local

make
if [ $? -eq 0 ];then

    echo "make is ok"
else
    echo "something is wrong"
    exit
fi
make install
if [ $? -eq 0 ];then

    echo "make install is ok"
else
    echo "something is wrong"
    exit
fi

ln -s /usr/local/python2.7 /usr/bin/python

sleep 1

echo "开始安装setuptools"
cd /data/x5online/tools

tar xf setuptools-14.3.1.tar.gz

cd setuptools-14.3.1

python setup.py install
if [ $? -eq 0 ];then

    echo "setup is ok"
else
    echo "something is wrong"
    exit
fi

sleep 1

echo "开始安装pip"

cd /data/x5online/tools

tar xf pip-9.0.1.tar.gz

cd pip-9.0.1

python setup.py install

if [ $? -eq 0 ];then

    echo "all is ok"
else
    echo "something is wrong"

fi

然后使用ansible all -m copy "src=/data/x5online/install_python.sh dest=/data/x5online"分发至所有需要升级python的服务器

最后ansible all -m shell "/data/x5online/install_python.sh"执行脚本。

时间: 2024-10-10 09:09:29

centos6.5升级python为2.7的相关文章

centos6.3升级python至2.7.5

centos6.3自带的python版本是2.6.6,有时候需要升级到2.7.这里记录一下升级过程,方便查阅.实际上是转载自http://flyingdutchman.iteye.com/blog/1885564. 1.安装gcc. yum install gcc gcc-c++ 2.下载python-2.7.5.tar.xz. wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.xz 3.解压安装 xz -d python

CentOS6.X升级Python

CentOS6.X升级Python CentOS6.X升级默认Python2.6.6到python2.7 在centos下直接输入python即可进入python,能看到当前版本信息 [[email protected] ~]# pythonPython 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2Type "help", "copyright

CentOS6.5升级Python

centos6.5的python版本默认是2.6.6,可能有的时候我们需要升级到更高的版本,那就来动手升级下吧.我这里以2.7.8版本为例,根据实际需要选择升级版本即可. yum install -y gcc gcc-c++ make readline-devel wgetwget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz tar zxvf Python-2.7.8.tgzcd Python-2.7.8./configure

centos6.4升级python到2.7(转)

由于aliyun上面centos6.4系统默认的python版本是python2.6.6,无法满足需求,决定升级到python2.7. Python官网上面有两个版本python3.4.x和python2.7.x.由于绝大多数开发python2.7已满足需求,所以我这里采用的是python2.7.8. 以下为升级的具体步骤: 1.下载.解压.编译.安装,由于系统中yum依赖旧版的python,所以不能卸载安装,这里采用全新安装. 1.tar -xvf Python-2.7.8.tar.xz 2.

Centos6.6升级Python与安装ipython、pip小结

CentOS6.6自带的Python版本为2.6.6,想给他升级一下,安装Python2.7.9 一.准备安装包  wget https://bootstrap.pypa.io/get-pip.py #下载setuptools和pip  wget https://pypi.python.org/packages/source/i/ipython/ipython-3.1.0.tar.gz #下载ipython  wget https://www.python.org/ftp/python/2.7.

centos6.6升级python

需求:python 2.6.6升级到python 2.7.9 wgt https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tg tar xf Python-2.7.9.tgz cd Python-2.7.9 ./configure make allmake installmake cleanmake distclean 按装后python -V 查看当前版本还是python 2.6.6 mv /usr/bin/python /usr/bin/

centos6.4升级Python过程总结

1.查看Python环境: python -V 2.下载Python包并解压 cd /usr/local/src/   #不一定在这个目录下,只是我习惯在此目录 wget wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 tar xf  Python-2.7.3.tar.bz2 3.编译安装 cd Python-2.7.3 ./configure make && make install 4.创建软连接 mv /usr

centos6.5 升级python 到 python 2.7.11 安装 pip

1.首先官方下载源码,然后安装(./configure,make all,make install,make clean,make distclean) 注意:需要先安装zlib-devel,openssl-devel,这个在之后安装pip时需要,否则之后需要重新编译安装python2.7.11 另外:yum 无法使用python2.7,所以在将/usr/bin/python 软连指向/usr/local/bin/python2.7.11后,需要将/etc/yum文件的头部 #!/usr/bin

CentOS6.5升级Python到2.7并安装pip

1.下载安装python2.7 安装前准备: yum install zlib-devel openssl-devel -y 注:在编译安装python2.7之前必须先安装zlib-devel包,不然在安装setuptools时会出现以下错误: AttributeError: 'NoneType' object has no attribute 'decompressobj' 下载安装: wget wget http://python.org/ftp/python/2.7.3/Python-2.