CentOS 6 系列 安装 Python2.7+pip

摘要
刚刚装上的CentOS6系列系统,默认是Python2.6的老版本,需要升级一下,而yum默认采用Python2.6的,所以需要二者共存,新装的系统往往各种包都不全,需要比较繁琐的步骤:
1.更新gcc
一定要安装openssl哦,不然pip没法用滴,readline-devel可以使2.7在命令行下上下左右哦

yum -y install zlib zlib-devel wget gcc gcc-c++ openssl openssl-devel readline-devel

2.下载Pthon2.7源码安装包

wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
cd Python-2.7
mkdir /usr/local/python2.7
./configure --prefix=/usr/local/python2.7
make && make install

#yum
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
vi  /usr/bin/yum
    #!/usr/bin/python ---> #!/usr/bin/python2.6

3.下载pip,setuptools

官网下载pip最新版:https://pypi.python.org/pypi/pip/8.1.2#downloads
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
tar xvf setuptools-1.4.2.tar.gz
cd setuptools
python setup.py install
wget --no-check-certificate https://pypi.python.org/packages/source/pip/pip-6.0.7.tar.gz
tar xvf pip-6.0.7.tar.gz
cd pip-6.0.7
python setup.py install

你可能感兴趣的:(python,linux)