python-配置pip源

可以配置pip源的路径:
三种形式:
1.Per-user:
UNIX default configuration fileHOME/.config/pip/pip.confmacOHOME/Library/Application Support/pip/pip.conf
HOME/.config/pip/pip.conf(HOME/Library/Application Support/pip/不存在)
Windows:%APPDATA%pippip.ini
legacy per-user configuration file(遗留的per-user配置方式):
UNIX:$HOME/.pip/pip.conf
Windows:%HOME%pippip.ini

2.Inside a virtualenv:
Unix and macOS:$VIRTUAL_ENV/pip.conf
Windows:%VIRTUAL_ENV%pip.ini

3.Site-wide:
Unix:/etc/pip.conf
MacOS:/Library/Application Support/pip/pip.conf
Windows XP:C:Documents and SettingsAll UsersApplication Datapippip.ini
Windows7或之后:C:ProgramDatapippip.ini

系统读取顺序(注意后面会覆盖前面):

1.Firstly the site-wide file is read, then
2.The per-user file is read, and finally
3.The virtualenv-specific file is read.

笔者使用的是windows7,将pip.ini配置在%APPDATA%pip下。
如果不清楚%APPDATA%在哪里,可以进入cmd,输入set命令。
如图所示:
这里写图片描述
在%APPDATA%下创建pip文件夹,在pip文件夹下创建pip.ini文本文件。
这里写图片描述
其中index-url指定的是pip源ip地址
笔者使用的是清华大学源。国内比较好用的源有:
pypi.python.org 官方源
pypi.douban.com 豆瓣源,福州
pypi.hustunique.com 华中科技大学源,武汉
pypi.tuna.tsinghua.edu.cn 清华源,北京

http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学

不嫌麻烦的话,也可以手动指定源
pip install -i xx(其中xx是指定的源ip地址)

参考网址:
https://pip.pypa.io/en/latest/user_guide/

原文地址:https://www.cnblogs.com/kevincong/p/7801906.html