python快速下载第三方包

一、说在前面

我在用pip下载包时经常有下载比较慢和如下错误的问题

Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pipenv/

 二、解决方法

 默认pip是使用Python官方的源,但是由于国外官方源经常被墙,导致不可用,我们可以使用国内的python镜像源,从而解决 Python安装不上库的烦恼。

上网也找了很多方法,最后记录下对我这种错误肯定管用的解决方案

关键命令:

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

相关解释:

   1. pip install 表示通过pip 来安装某种包

   2. xxx     表示你要安装的包名,比如pipenv,jupyter等等

        3. -i http://pypi.douban.com/simple       表示将镜像地址切换为国内,这里切换到了豆瓣

   4.--trusted-host pypi.douban.com    表示将指定网站设置为信任服务器

附:

常用的镜像地址有: 

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

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

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

4) https://pypi.tuna.tsinghua.edu.cn/simple/   清华大学

5)  http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学

三、效果

原文地址:https://www.cnblogs.com/20183544-wangzhengshuai/p/14320143.html