#阿里云
http://mirrors.aliyun.com/pypi/simple/
#中国科技大学
https://pypi.mirrors.ustc.edu.cn/simple/
#豆瓣(douban)
http://pypi.douban.com/simple/
#清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
#中国科学技术大学
http://pypi.mirrors.ustc.edu.cn/simple/
pip install --help
可以看到:
Package Index Options (including deprecated options):
-i, --index-url Base URL of Python Package Index (default https://pypi.python.org/simple). This should point to a repository compliant with
PEP 503 (the simple repository API) or a local directory laid out in the same format.
--extra-index-url Extra URLs of package indexes to use in addition to --index-url. Should follow the same rules as --index-url.
--no-index Ignore package index (only looking at --find-links URLs instead).
-f, --find-links If a url or path to an html file, then parse for links to archives. If a local path or file:// url that's a directory, then
look for archives in the directory listing.
--process-dependency-links Enable the processing of dependency links.
因此我们临时更改安装源可以使用-i
或者使用--index-url
(含义更明显)选项来实现;
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
修改或者创建~/.pip/pip.conf
为,以清华源为例:
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
修改或者创建文件C:\Users\${UserName}\AppData\Roaming\pip\pip.ini
,${UserName}
可通过cmd执行指令set Username
获得,也就是当前用户的用户名;修改内容如下,以阿里源为例:
[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
- timeout 超时设置
- index-url 源,可以换成其他的源
- trusted-host 添加源为可信主机,要不然可能报错
- disable-pip-version-check 设置为true取消pip版本检查,排除每次都报最新的pip, 不推荐添加