pip配置

作者: 小强0_0 | 来源:发表于2017-10-18 20:40 被阅读0次

因资源问题导致pip下载速度比较慢,使用国内镜像可以大大提高下载速度

国内镜像

1.豆瓣镜像

http://pypi.douban.com/simple/

2.阿里镜像

http://mirrors.aliyun.com/pypi/simple/

安装(以豆瓣为例)

配置方法

vim ~/.pip/pip.conf

如果没有~/.pip/pip.conf则新建

pip.conf中加入内容:

[global]
index-url = http://pypi.douban.com/simple

配置后使用pip安装后可能会提示:

The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host mirrors.aliyun.com'.

需要在使用pip安装第三方包时加入
--trusted-hostpypi.douban.com
以安装requests为例:
pip install requests --trusted-host mirrors.aliyun.com
然而这样就使得安装过程都变得非常复杂,为了一劳永逸,需要在pip.conf文件里加入

trusted-host=mirrors.aliyun.com```

最终配置文件如下:
[pip.conf]

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

相关文章

网友评论

      本文标题:pip配置

      本文链接:https://www.haomeiwen.com/subject/afaeuxtx.html