更换pip的源为国内源
通常使用pip安装模块时都默认访问Pypi的官方源,速度慢还经常超时,为了提高速度和稳定性,我们可以将其更换为国内的镜像。
Mac && Linux
修改源可以在~/
创建.pip/pip.conf
,填入如下内容:
1 | [global] |
Windows
对于Windows用户来说,在%APPDATA%
创建pip\pip.ini
,填入如下内容:
1 | [global] |
临时更换
懒得修改也可以使用-i
参数临时指定源
1 | pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com |
对于非https的源,需要添加--trusted-host
,否则会提示错误。
其他源推荐
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment