1、pip安装包下载
进入下载地址下载.tar.gz压缩包。
2、安装pip
| yum install -y pipyum install -y pip3
 
 | 
| sudo apt-get install -y pipsudo apt-get install -y pip3
 
 | 
| # 解压压缩包tar -xzvf pip-1.5.4.tar.gz
 
 # 进入解压文件
 cd pip-1.5.4
 
 # 安装
 python setup.py install
 
 | 
3、升级pip
| python -m pip install --upgrade pip
 | 
| pip install --upgrade pip
 | 
4、pip安装第三方包
5、pip查看是否已安装
| pip show --files 安装包名
 # 输出
 Name:SomePackage                                # 包名
 Version:1.0                                     # 版本号
 Location:/my/env/lib/pythonx.x/site-packages    # 安装位置
 Files:
 ../somepackage/__init__.py [...]                # 包含文件等等
 
 | 
6、pip检查哪些包需要更新
7、pip升级包
| pip install --upgrade 要升级的包名
 # 先卸载已安装的,再进行安装
 pip install --upgrade --force-reinstall requests==2.6.0
 
 # 不会卸载已安装的,孤立已安装的旧文件,再进行安装,孤立的文件只能手动清理
 pip install --upgrade --ignore-installed requests==2.6.0
 
 | 
8、pip卸载包
9、导出安装的库到list.txt
10、导入list.txt中列出的库到系统
11、下载离线安装包
| pip download -d 路径 -r requirments.txt
 | 
12、利用离线包安装,首先切换到离线包所在路径
| pip install --no-index --find-links=路径 -r requirments.txt
 | 
13、更换pip镜像源
在用户目录下创建一个命名为<.pip>的文件夹,在该文件夹下创建一个命名为<pip.conf>的文件,在该文件中写入以下内容:
| [global]timeout=100
 index-url=https://mirrors.aliyun.com/pypi/simple
 
 [install]
 trusted-host=mirrors.aliyun.com
 
 
 | 
在用户目录下创建一个命名为的文件夹,在该文件夹下创建一个命名为<pip.ini>的文件,在该文件中写入以下内容:
| [global]index-url=https://mirrors.aliyun.com/pypi/simple/
 
 [install]
 trusted-host=mirrors.aliyun.com
 
 | 
14、pip参数解释
| pip --help
 Usage:  pip<command>[options]
 Commands:
 install                   安装包.
 uninstall                 卸载包.
 freeze                    按着一定格式输出已安装包列表
 list                      列出已安装包.
 show                      显示包详细信息.
 search                    搜索包,类似yum里的search.
 wheel                     Buildwheelsfromyourrequirements.
 zip                       不推荐.Zipindividualpackages.
 unzip                     不推荐.Unzipindividualpackages.
 bundle                    不推荐.Createpybundles.
 help                      当前帮助.
 
 GeneralOptions:
 -h,--help                 显示帮助.
 -v,--verbose              更多的输出,最多可以使用3次
 -V,--version              现实版本信息然后退出.
 -q,--quiet                最少的输出.
 --log-file<path>          覆盖的方式记录verbose错误日志,默认文件:/root/.pip/pip.log
 --log<path>               不覆盖记录verbose输出的日志.
 --proxy<proxy>            Specifyaproxyintheform[user:passwd@]proxy.server:port.
 --timeout<sec>            连接超时时间(默认15秒).
 --exists-action<action>   Defaultactionwhenapathalreadyexists:(s)witch,(i)gnore,(w)ipe,(b)ackup.
 --cert<path>              证书.
 
 |