CentOS6 Python 2.7 安装

准备工作

下载源码包
python
setuptools
pip

安装make工具
yum -y install gcc automake autoconf libtool make

安装zlib
yum -y install zlib-devel

安装openssl
yum -y install 'openssl*'

安装bzip2依赖库
yum -y install 'bzip2*'

安装解压工具
yum -y install xz unzip

编译安装

xz -d
tar xvf
cd 
vi Modules/Setup.dist

找到

#SSL=/usr/local/ssl
#_ssl _ssl.c \
#       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
#       -L$(SSL)/lib -lssl -lcrypto
......
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz 

去掉注释
编译

./configure --prefix=/usr/local/python2.7
make all 
make install
make clean
make distclean

安装成功

~#/usr/local/python2.7/bin/python2.7
Python 2.7.3 (default, Dec 18 2013, 15:43:35) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

建立软链

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

解决yum无法使用

vi /usr/bin/yum
----------------------------------------------------
#!/usr/bin/python
import sys
try:
    import yum
except ImportError:
.......

修改为

#!/usr/bin/python2.6
........

安装python-pip工具

先安装setuptools

unzip
cd
python setup.py install

安装pip

tar zxvf 
cd
python setup.py install
ln -s /usr/local/python2.7/bin/pip /usr/bin/pip

你可能感兴趣的:(CentOS6 Python 2.7 安装)