安装PIP
#下载get-pip.py并执行即可安装pip
curl https://bootstrap.pypa.io/get-pip.py
python get-pip.py
更新PIP
#Linux 或 OSX
pip install -U pip
#Windows
python -m pip install -U pip
基础功能
#安装一个第三方库
pip install 第三方库名称
pip install 第三方库名称=版本号
#卸载一个第三方库
pip uninstall 第三方库名称
#搜索一个第三方库(搜索速度超慢)
pip search 第三方库名称
#查看已经安装了哪些第三方库
pip list
#查看已经安装第三方库的最新版本
pip list --outdated
#更新第三方库
pip install --upgrade 第三方库名称
用国内镜像源增速PIP
#命令增速
pip install 第三方库名称 -i
#修改配置文件设置国内镜像源为默认镜像
#要配制成默认的话,需要创建或修改配置文件(linux的文件在~/.pip/pip.conf,windows在%HOMEPATH%\pip\pip.ini),修改内容为:
[global]
index-url = http://pypi.douban.com/simple
#PyPi国内镜像源一览
http://pypi.douban.com/ 豆瓣
http://pypi.hustunique.com/ 华中理工大学
http://pypi.sdutlinux.org/ 山东理工大学
http://pypi.mirrors.ustc.edu.cn/ 中国科学技术大学
PIP常见套路---快速创建项目环境
# 导出当前环境下的所有第三方库
pip freeze > requirements.txt
# 在新环境下安装所有文件内的第三方库
pip install -r requirements.txt
PIP常见套路---与wheel的结合使用
#安装wheel
pip install wheel
# 导出当前环境下的所有第三方库
pip freeze > requirements.txt
#将当前所有第三方库打成wheel包
#并保存在当前目录的backup文件夹下
pip wheel --wheel-dir=".\backup" -r requirements.txt
#从备份文件夹中安装第三方库
pip install --use-wheel --no-index --find-links=".\backup" -r requirements.txt
引用:
使用国内镜像源来加速python pypi包的安装