centos6.5安装pip方法
pip类似RedHat里面的yum,安装Python包非常方便。本节详细介绍pip的安装、以及使用方法。
一、pip下载安装
1.1 pip下载
wget “https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb” –no-check-certificate
1.2 pip安装
# tar -xzvf pip-1.5.4.tar.gz
# cd pip-1.5.4
# python setup.py install
1.3 如果pip安装后提示依然没有pip命令,需在在添加环境变量
# vim /etc/profile
在文档最后,添加:
export PATH=”/usr/local/python2.7/bin:$PATH”
保存,退出
然后运行:
#source /etc/profile
二、查看pip版本
pip -V
pip 1.5.4 from /usr/local/python2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
三、pip使用详解
3.1 pip安装包
pip install paramiko
[…]
Successfully installed paramiko
3.2 pip查看已安装的包
[root@test1]# pip show –files paramiko
—
Name: paramiko
Version: 1.16.0
Location: /usr/local/python2.7/lib/python2.7/site-packages
Requires: pycrypto, ecdsa
Files:
Cannot locate installed-files.txt
3.3 pip检查哪些包需要更新
[root@test1 /]# pip list –outdated
setuptools (Current: 0.6c11 Latest: 19.2)
pip (Current: 1.5.4 Latest: 7.1.2)
Django (Current: 1.8.5 Latest: 1.9.1)
3.4 pip升级包
pip install –upgrade Django
3.5 pip卸载包
pip uninstall Django
四、常见错误
4.1 ImportError No module named setuptools解决办法
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python setup.py build
python setup.py install
4.2 ImportError: cannot import name HTTPSHandler解决办法
yum安装openssl和openssl-devel,然后重新编译python
五、pip参数解释
# pip –help
Usage:
pip <command> [options]
Commands:
install 安装包.
uninstall 卸载包.
freeze 按着一定格式输出已安装包列表
list 列出已安装包.
show 显示包详细信息.
search 搜索包,类似yum里的search.
wheel Build wheels from your requirements.
zip 不推荐. Zip individual packages.
unzip 不推荐. Unzip individual packages.
bundle 不推荐. Create pybundles.
help 当前帮助.
General Options:
-h, –help 显示帮助.
-v, –verbose 更多的输出,最多可以使用3次
-V, –version 现实版本信息然后退出.
-q, –quiet 最少的输出.
–log-file <path> 覆盖的方式记录verbose错误日志,默认文件:/root/.pip/pip.log
–log <path> 不覆盖记录verbose输出的日志.
–proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
–timeout <sec> 连接超时时间 (默认15秒).
–exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
–cert <path> 证书.
来源:https://www.cnblogs.com/senzhe/p/5804092.html