pip配置

因资源问题导致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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容