CentOS6.5二进制包升级Python

升级自带2.6.6版本到2.7.12

1.下载解压Python-2.7.12.tar.xz

xz -d Python-2.7.12.tar.xz
tar -xvf Python-2.7.12.tar

2.必要时安装以下依赖,或根据编译情况解决依赖

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

3.安装Python

cd Python-2.7.12
./configure --prefix=/usr/local/python
make
make altinstall #altinstall可以避免安装时创建任何软连接

4.建立连接

mv /usr/bin/python{,.old}
ln -s /usr/local/python/bin/python2.7 /usr/bin/python

5.安装pip和setuptools

下载get-pip.py,在pypi里setuptools的安装文档中有下载链接

python get-pip.py

mv /usr/bin/pip{,.old}
ln -s /usr/local/python/bin/pip /usr/bin/pip

mv /usr/bin/easy_install{,.old}
ln -s /usr/local/python/bin/easy_install /usr/bin/easy_install

6.修复yum,修改/usr/bin/yum

#!/usr/bin/python #修改前
#!/usr/bin/python.old #修改后

EOF

posted @ 2017-12-18 15:07  星丿空  阅读(181)  评论(0编辑  收藏  举报