Python pip 简单使用
Python pip 简单使用
- 每次使用 pip 命令都需要百度一下镜像源,实在麻烦,做个文档记录一下。
1 pip 常用命令
| 命令 | 说明 | 实例 |
|---|---|---|
install |
安装指定软件包 | pip install numpy |
list |
列出已安装的软件包 | pip list |
--trusted-host <hostname> |
将此 host 标记为受信任的,即使没有有效的 HTTPS |
pip install request -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com |
2 pip 常用操作
- 使用
requirements.txt安装包:
1 | pip install -r requirements.txt |
- 安装过慢,可以直接换源,未避免
SSL错误,授信站点:
1 | pip install open_clip -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com |
- 结合一下,常用的命令为:
1 | pip install -r requirements.txt -i http://pypi.douban.com/simple/ |
- 但每次都换源比较麻烦,直接设置一个
pip配置文件。
2.1 Linux
- Linux:修改
~/.pip/pip.conf(没有就创建一个)
1 | [global] |
2.2 Windows
- Windows:修改
%USERPROFILE%\pip\pip.ini(没有就创建一个)
1 | [global] |
3 pip 常用源
1 | 豆瓣:http://pypi.douban.com/simple/ |




