签到成功

知道了

CNDBA社区CNDBA社区

Python RequestsDependencyWarning: urllib3 告警 解决方法

2023-04-21 18:25 3272 0 原创 Python
作者: dave

1 问题现象

python 脚本运行的时候每次都会有个告警,虽然能执行,但告警会影响对结果的处理:http://www.cndba.cn/cndba/dave/article/116567

http://www.cndba.cn/cndba/dave/article/116567
http://www.cndba.cn/cndba/dave/article/116567

[dave@www.cndba.cn AIDB]# python aidb.py 
/usr/lib/python2.7/site-packages/requests/__init__.py:104: RequestsDependencyWarning: urllib3 (1.26.7) or chardet (2.2.1)/charset_normalizer (None) doesn't match a supported version!
  RequestsDependencyWarning)
('====Begin Time: ', '2023-04-21 18:11:06')
('====End Time: ', '2023-04-21 18:11:29')

2 解决方法

先卸载包:

http://www.cndba.cn/cndba/dave/article/116567
http://www.cndba.cn/cndba/dave/article/116567
http://www.cndba.cn/cndba/dave/article/116567
http://www.cndba.cn/cndba/dave/article/116567

[dave@www.cndba.cn AIDB]# pip2 uninstall urllib3 chardet

在重新安装requests :http://www.cndba.cn/cndba/dave/article/116567http://www.cndba.cn/cndba/dave/article/116567http://www.cndba.cn/cndba/dave/article/116567

[dave@www.cndba.cn site-packages]# pip2 install requests --force-reinstall
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/requests/
Collecting requests
  Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting urllib3<1.27,>=1.21.1
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fb2fb6629d0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /packages/7b/f5/890a0baca17a61c1f92f72b81d3c31523c99bec609e60c292ea55b387ae8/urllib3-1.26.15-py2.py3-none-any.whl
  Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
     |████████████████████████████████| 140 kB 132 kB/s 
Collecting idna<3,>=2.5; python_version < "3"
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 25 kB/s 
Collecting chardet<5,>=3.0.2; python_version < "3"
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 17 kB/s 
Installing collected packages: certifi, urllib3, idna, chardet, requests
  Attempting uninstall: certifi
    Found existing installation: certifi 2021.10.8
    Uninstalling certifi-2021.10.8:
      Successfully uninstalled certifi-2021.10.8
  Attempting uninstall: urllib3
    Found existing installation: urllib3 1.25.6
    Uninstalling urllib3-1.25.6:
      Successfully uninstalled urllib3-1.25.6
  Attempting uninstall: idna
    Found existing installation: idna 2.10
    Uninstalling idna-2.10:
      Successfully uninstalled idna-2.10
  Attempting uninstall: chardet
    Found existing installation: chardet 3.0.4
    Uninstalling chardet-3.0.4:
      Successfully uninstalled chardet-3.0.4
  Attempting uninstall: requests
    Found existing installation: requests 2.27.1
    Uninstalling requests-2.27.1:
      Successfully uninstalled requests-2.27.1
Successfully installed certifi-2021.10.8 chardet-4.0.0 idna-2.10 requests-2.27.1 urllib3-1.26.15
WARNING: You are using pip version 20.3.4; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python2 -m pip install --upgrade pip' command.

验证没有告警了:

[dave@www.cndba.cn site-packages]# cd /data/AIDB/
[dave@www.cndba.cn AIDB]# python aidb.py 
('====Begin Time: ', '2023-04-21 18:19:40')
('====End Time: ', '2023-04-21 18:20:13')

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:8013132次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ