cmd安装python镜像_python解决使用镜像源来安装包

一、问题

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

报错代码

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(‘: 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(‘: 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(‘: 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(‘: 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(‘: 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升级的,据此解决了前面遇到的问题

原文:https://www.cnblogs.com/future-dream/p/11055888.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值