Python学习:解决pip总是WARNING: Retrying (Retry(total=4...

我在今天学习Python 3的过程中,遇到了一个头疼的问题,当我使用pip指令的时候总是告诉我,

 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError...

通过我不懈的浏览器搜索,我发现了解决之道!

pip install [whatyouwant] -i url

没错,就是这个上述的指令,大家只要把[whatyouwant]替换成自己需要的包就好啦!搞定!
其实问题本身大家看报错就能看出来,主要就是连接超时了,所以我们只要用一些国内的pip源就可以完美的解决。
下面有几个国内的pip源,供大家参考:

阿里云 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/

举个例子看看怎么用的(假如我想要安装openpyxl的包):

pip install openpyxl -i http://pypi.douban.com/simple

这样就可以安装openpyxl的包啦。

如果很不幸,你出现了下面这个问题,

WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. 
If this repository is available via HTTPS we recommend you use HTTPS instead, 
otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.douban.com'.

那么你应该尝试这个命令:

pip install [whatyouwant] -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

这样就可以完美的解决这个问题啦!

  • 138
    点赞
  • 377
    收藏
    觉得还不错? 一键收藏
  • 21
    评论
在PyCharm中,当使用pip安装时出现"WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)"的错误提示时,这可能是由于网络连接超时或限制导致的。以下是一些解决方法: 1. 通过指定安装源来解决:在使用pip命令时,可以通过添加"-i"参数加上特定的安装源来解决此问题。例如,可以使用豆瓣源来安装requests库: ``` pip install requests -i http://pypi.douban.com/simple --trusted-host pypi.douban.com ``` 这样可以提供一个更稳定且快速的安装源,以解决连接超时的问题。 2. 关闭系统代理:有时候,系统开启了代理可能会导致安装失败。请确保关闭系统代理后再次尝试安装。 3. 升级Python版本:如果你的Python版本过低,可能会导致一些问题。可以尝试升级Python版本来解决问题。 4. 允许警告:在使用pip安装时,可以尝试允许警告来解决问题。例如,在安装命令中添加"--trusted-host"参数,并指定相应的主机名: ``` pip install dark -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com ``` 这样可以解决某些连接问题。 希望这些解决方法可以帮助你解决在PyCharm中pip安装出错的问题。如果问题仍然存在,请参考提供的参考链接获取更多帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [pycharm安装模块报错“WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, ...](https://blog.csdn.net/l18032223283/article/details/129188137)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [pycharm中pip安装出错WARNING:Retrying(Retry(total=4,connect=None,read=None,redirect=None,status=None)...](https://blog.csdn.net/shanlijia/article/details/123963801)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值