pip 安装

初始化系统 安装PIP 问题?

一、更新Python 至2.7以上

yum install wget gcc gcc-c++ -y

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

tar -xf Python-2.7.6.tgz 

mv Python-2.7.6 /usr/local/python

cd /usr/local/python/

./configure --prefix=/usr/local/python/

make &&make install

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

验证:python -v


二、安装 pip

wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9

tar -xf pip-9.0.1.tar.gz 

mv pip-9.0.1 /usr/local/pip

python setup.py install

1、提示报错:?

ImportError: No module named setuptools   

 则安装 setuptools 


三、setuptools 插件安装 

wget wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz

tar -xf setuptools-2.0.tar.gz 

mv setuptools-2.0 /usr/local/pip/setuptools

cd /usr/local/pip/setuptools/

python setup.py install 

1、又提示报错:?

Compression requires the (missing) zlib module

没有 zlib 模块;这个可以直接 yum 安装 (yum 完成之后需要重新编译python )

yum install zlib zlib-devel -y

2、 python 重新编译

cd /usr/local/python/

make &&make install

3、安装 setuptools

cd /usr/local/pip/setuptools

python setup.py install

4、安装pip

cd /usr/local/pip

python setup.py install


5、创建pip软链接

ln -s /usr/local/python27/bin/pip  /usr/bin/pip

至此pip 就安装好了 ;

6、pip -V 验证版本;就可以使用python  pip 安装更新文件了

[root@localhost pip]# pip --version

pip 9.0.1 from /usr/local/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)