linux 版本: CentOS 6 (Linux version 4.10.5-1.el6.elrepo.x86_64 )
10 安装wget
yum -y install wget
20 查看原Python版本
[root@host ~]# python -V
Python 2.6.6
30 安装升级相应的软件包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
40 下载python 2.7 的源码包 (wget会把软件包下载到当前目录下)
wget http://mirrors.sohu.com/python/2.7.6/Python-2.7.6.tgz
50 解压
tar zxf Python-2.7.6.tgz -C /usr/local/src/
60 安装
cd /usr/local/src/Python-2.7.6/
./configure --prefix=/usr/local/python2.7
make && make install
70 配置python
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
80 查看版本
[root@host Python-2.7.6]# python -V
Python 2.7.6
------------------------------------------------------------------------------------------------------
附1: easy_install的安装
1.
wget --no-check-certificat https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
2.
tar zxf setuptools-2.0.tar.gz
3.
cd setuptools-2.0
4.
python2.7 setup.py install
5. 配置
ln -sf /usr/local/python2.7/bin/easy_install-2.7 /usr/bin/easy_install-2.7
------------------------------------------------------------------------------
附2 pip安装
1.下载pip安装包
wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz --no-check-certificate
2.解压安装
tar -xzvf pip-1.3.1.tar.gz
cd pip-1.3.1
python setup.py install