快速解决urllib3.exceptions.MaxRetryError: HTTPSConnectionPool

正题

使用pip命令查看urllib3版本
pip list
发现版本为 1.26.9
urllib3  v1.26.9
此时如下报错,无法正常使用(使用了代理)
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='xxx.xxxxx.com', port=443): Max retries exceeded with url: /xxxxxxxxxx (Caused by ProxyError('Cannot connect to proxy.', TimeoutError('_ssl.c:980: The handshake operation timed out')))

因为我必须要走代理,所以不能在代码里通过强制不走代理的方法避免此报错
此时只需要 安装低版本urllib3 (v1.2.3)

使用pip命令安装urllib3 v1.2.3
pip3 install urllib3==1.23
修改项目requirements.txt文件中的urllib3版本号,项目没有requirements文件的忽略
urllib3~=1.2.3
再次运行,程序正常执行,但会有警告
C:\Python310\lib\site-packages\urllib3\connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn((
直接到connectionpool.py的对应路径找到connectionpool.py打开编辑器找到852行,把警告注释
# if not conn.is_verified:
#     warnings.warn((
#         'Unverified HTTPS request is being made. '
#         'Adding certificate verification is strongly advised. See: '
#         'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
#         '#ssl-warnings'),
#         InsecureRequestWarning)
完工

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值