CentOS6.4升级python2.7.6

升级说明:在升级python之前,必须保证pip/setuptools未安装, 否则会有各种巨坑。

一. 升级前的准备

     先安装必要的包,次步不做的话,后面会有各种各样的坑等着你j_0069.gif ,乖乖的装吧!

yum install readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel libdbi-devel ncurses-libs zlib-devel -y

二.下载

(1)下载地址:

wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz

tar -zxvf Python-2.7.6.tgz

cd Python-2.7.6

./configure --prefix=/usr/local/python2.7

make && make install

make clean

make distclean

mv /usr/bin/python /usr/bin/python2.6.6

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



以下修改是为了使yum能够正常使用

# vim /usr/bin/yum

将第一行注释部分的 

#!/usr/bin/python 修改为

#!/usr/bin/python2.6.6


(2) 下载并安装setuptools

    wget http://pypi.douban.com/packages/source/s/setuptools/setuptools-12.0.5.tar.gz

    tar zxvf setuptools-12.0.5.tar.gz

    cd setuptools-12.0.5

    python setup.py build

    python setup.py install


环境变量

vi /etc/profile

添加如下内容:

PY_EZ=/usr/local/python2.7

export PATH=$PY_EZ/bin:$PATH

source /etc/profile  # 当前终端生效,reboot后才会完全生效

echo $PATH



(3)安装pip

easy_install -i http://pypi.douban.com/simple pip


你可能感兴趣的:(centos,python,升级)