首页 > 编程语言 >【Python】pip intall 遇到了WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, stat

【Python】pip intall 遇到了WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, stat

时间:2023-04-10 15:56:22浏览次数:42  
标签:redirect status None http urllib proxyServer https proxies

具体可能会遇到的是以下这些情况:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))'
requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.baidu.com.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))
症状原因: windows系统使用了全局代理
python 旧版的urllib 在生成https代理变量的时候会把本地的http代理添加为https。
运行下方代码: import urllib.request proxies = urllib.request.getproxies_registry() print(proxies) 运行结果: {'http': 'http://xxxxx', 'https': 'https://xxxxx', 'ftp': 'http://xxxxx'}
具体问题部分代码 【request.py 里面的 getproxies_registry()】:(就是这片代码当时的判断没做好,导致到其他新版模块出错,这个问题在后续的更新完善了,所以我选择了解决方案四)                     if proxyServer[:5] == 'http:':                         proxies['http'] = proxyServer                     else:                         proxies['http'] = 'http://%s' % proxyServer                         proxies['https'] = 'https://%s' % proxyServer                         proxies['ftp'] = 'ftp://%s' % proxyServer
解决方案有几个 一、在运行代码之前先设置好本地的代理环境: import os os.environ['HTTPS_PROXY'] = 'http://your-https-proxy:port' 注意是要http: 不是https:
二、修改urllib代码,让它兼容当前的其他包 proxies['https'] = 'https://%s' % proxyServer 这一行注释 或者修改为 proxies['https'] = 'http://%s' % proxyServer
三、降级使用(建议古老的代码什么的使用) 把pip requests urllib3 降级到 2020年以前的版本就能正常使用了 requests           2.20.1 urllib3            1.24.3 pip                20.2.2
四、将python升级到3.11版本(我的选择) 我出问题的是3.7.0,之前一直在用的旧包,所以都是正常的,后面硬盘坏了,虽然python3.7.0装回去了 但是在安装urllib3,跟requests的时候它默认是安装的最新版,也就出现了用着2017年还是19年的urllib配合着urllib3跟requests
具体哪个版本修复了以上问题我这边不是太清楚,升级后就正常了
更新完之后运行下方代码: import urllib.request proxies = urllib.request.getproxies_registry() print(proxies) 运行结果就变成了: {'http': 'http://xxxxx', 'https': 'http://xxxxx', 'ftp': 'http://xxxxx'}



标签:redirect,status,None,http,urllib,proxyServer,https,proxies
From: https://www.cnblogs.com/RexTooru/p/17303168.html

相关文章

  • nohup: ignoring input and redirecting stderr to stdout
    把后面的“&”改成“2>&1&”,把启动命令改成如下:nohupjava-jareureka-server.jar>../logs/eureka-server.out2>&1&再次执行,问题解决。解释如下:2>表示把标准错误(stderr)重定向,标准输出(stdout)是1。尖括号后面可以跟文件名,或者是&1,&2,分别表示重定向到标准输出......
  • NuGet Response status code does not indicate success: 401 (Unauthorized).
    Retrying'FindPackagesByIdAsyncCore'forsource'https://nexus-cn/repository/nuget-group/FindPackagesById()?id='Moq'&semVerLevel=2.0.0'.Anerroroccurredwhilesendingtherequest.Therequestwasaborted:Therequest......
  • ERROR: Could not find a version that satisfies the requirement pymysql (from ver
    踩过的坑不管是idea中直接引入还是 pip3installpymysql都会报错:ERROR:Couldnotfindaversionthatsatisfiestherequirementpymysql(fromversions:none)  原因是网络问题,需要需要使用国内镜像源来加速,比如豆瓣源pipinstallpymysql-ihttp://pypi.douba......
  • java lambda List 查找 anyMatch() allMatch() noneMatch()
    packagelambda.list;importcn.hutool.core.util.ObjectUtil;importlombok.extern.slf4j.Slf4j;importorg.junit.Test;importpojo.Dome;importjava.util.ArrayList;importjava.util.List;/***@Author:xxx*@date2021/5/14**/@Slf4jpublicclassSe......
  • 杭电oj Realtime Status(利用快速幂)
    今天这个题我又又又是看大佬的题解。原因是我的暴力想法超时了…………大家可以先搜索一下什么是快速幂。(我看完之后了解的快速幂,就是通过放大底数以达到减小指数从而大幅减少运算次数的方法)这里就不赘述了,题目是这样的:对了,再啰嗦几句,由于这个题的数据量很大并且他只需要......
  • excel文件公式数据为None怎么办?
    #原因,包问题我用openpyxl操作完以后,带公式的值就读取不出来了;#编写操作,打开一个目录下的所有xlsx文件功能#所需要的依赖importwin32apiimportwin32conimportwin32processfromwin32comimportclientimportpsutildefkill(p_name="excel.exe"):pids=......
  • pandas中的inplace参数,将变量值赋给inplace= True 的结果,输出为none
    pandas中的inplace参数,将变量值赋给inplace=True的结果,输出为none#在学习drop函数是遇见将变量值赋给inplace=True的结果,输出为noneimportpandasaspdimportnum......
  • Installing Windows 7 on VirtualBox. Error status: 0xc0000225?
    Today,afterfinallytakingtheplungeintotheLinuxworld(I'mtryingtorefocusmyworktotheRailsecosystem),IinstalledVirtualBoxonLinuxMint13. Si......
  • Magento : Make 'Continue Shopping' button redirect to the product index page
    Magento:Make'ContinueShopping'buttonredirecttothelast-added-to-cartproduct'scategory Editcart.phtmlandreplacefollowingcode<?php......
  • 'NoneType' object has no attribute 'name'
     某个外键允许设置为空,null=True,blank=True,同时on_delete=models.SET_NULL当在Djangoadmin后台自定义标签的时候进行判断的时候,如果默认为空,提交数据库后会出现'NoneT......