pip使用国内镜像解决安装超时

刚刚用pip install pipenv时,发现抛出一个超时的问题

这是从files.pythonhosted.org去下载的,国内的网访问时慢的出奇,然后就会出现超时的情况。这时候,可以使用国内镜像

国内源:

清华:https://pypi.tuna.tsinghua.edu.cn/simple/

阿里云:http://mirrors.aliyun.com/pypi/simple/

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

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/ 

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

临时使用国内源:

一些博客上说使用 pip install -i 源地址 库名,但我发现这样说不行的,提示的意思是说:这个库所在的pypi.douban.com不是一个可信任的或安全的域名,因此将被忽略

所以需要加上--trusted-host pypi.douban.com pipenv,安装命令是:

pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com pipenv

这安装速度快多了

永久性使用国内源:

windows下,直接在user目录中创建一个pip目录,再新建文件pip.ini,内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

这种办法没有使用过,暂时记下来,以备不时之需

 

 

参考文章

https://www.cnblogs.com/wqpkita/p/7248525.html

https://blog.csdn.net/xiaoqu001/article/details/78630392

 

posted @ 2018-09-04 22:17  cnhkzyy  阅读(1432)  评论(0编辑  收藏  举报