一、问题
在进行python包安装的时候出现一个问题就是无法进行安装,且出现了如下的错误


报错代码

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000018D8B602160>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000018D8C9B5940>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000018D8C9B5B70>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000018D8C9B5DD8>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000018D8C9B5BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/pip/

 
二、解决
上面的原因是因为寝室网的问题,出现了链接超时或者是无法访问外网的原因,比如无法进入python的官网,这个就是问题的原因 。解决办法:
1.换一个网络
2.使用镜像地址,比如清华园,或者是豆瓣等镜像文件这样就可以进行下载以及正确的安装了。
指令:【pip install [包名] -i http://pypi.douban.com/simple --trusted-host pypi.douban.com】

三、结果


四、拓展
1.配置镜像文件这样就可以直接使用pip的指令来完成包的安装和数据的升级
2.首先在cmd中输入set,查看userprofile的位置,一般就在系统盘(C盘)下面的USER
3.在该目录下面建立一个pip的文件夹
4.在该文件下面建立一个pip.ini的文件
5.在该文件中写入如下内容,然后在保存。

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


结果图:

 

6.检验安装一个selenium和pip升级的,据此解决了前面遇到的问题

 

五、总结
可以看见使用命令就是【pip install [包名] -i [镜像源]】,或者使用一劳永逸法,注:如果http报错,就使用https协议
下面列举一些镜像源
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 
豆瓣(douban) http://pypi.douban.com/simple/ 
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

posted on 2019-06-20 00:13  蔚蓝色の天空  阅读(2945)  评论(0编辑  收藏  举报