python DeprecationWarning: 'urllib3[secure]'(弃用警告)

这两天执行python脚本的时候,总是会出现几个警告,虽然不影响运行,但是调试想看打印信息的时候,就很影响查询

1、问题

../.local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py:24
  /home/yyy/.local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py:24: DeprecationWarning: 'urllib3[secure]' extra is deprecated and will be removed in a future release of urllib3 2.x. Read more in this issue: https://github.com/urllib3/urllib3/issues/2680
    import urllib3

testcase/test_switch_window_handle.py: 24 warnings
  /home/yyy/.local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py:418: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
    if resp.getheader('Content-Type') is not None:

testcase/test_switch_window_handle.py: 24 warnings
  /home/yyy/.local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py:419: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
    content_type = resp.getheader('Content-Type').split(';')

image.png

2、解决

1)下载包

pip3 uninstall urllib3

2)重新安装request

pip3 install requests --force-reinstall
image.png

3)重新执行python脚本,警告信息就没有了

image.png

参考链接:
https://www.cndba.cn/dave/article/116567

你可能感兴趣的:(python DeprecationWarning: 'urllib3[secure]'(弃用警告))