urllib3 (1.26.6) or chardet (3.0.4) doesn't match a supported version! python dependency warnings

Written by - 0 comments

Published on August 19th 2021 - last updated on August 30th 2021 - Listed in Monitoring Python Coding


After upgrading one of the monitoring servers from Ubuntu 16.04 to 20.04, the check_esxi_hardware monitoring plugin added an annoying warning at the top of the output:

root@focal:~# /usr/lib/nagios/plugins/check_esxi_hardware.py -H esxiserver -U root -P "secret" -V hp
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.6) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

OK - Server: Cisco Systems Inc UCSC-C220-M5SX s/n: XXXXXXXXX Chassis S/N: XXXXXXXXX  System BIOS: C220M5.4.0.4c.0.0506190754 2019-05-06

Although the plugin works correctly, this warning is the first output and is therefore shown in the monitoring UI (here Icinga 2):

check_esxi_hardware python warnings in Icinga 2

Taking a closer look at the installed versions (from the Ubuntu packages):

root@focal:~# dpkg -l|grep urllib
ii  python3-urllib3 1.25.8-2ubuntu0.1                 all          HTTP library with thread-safe connection pooling for Python3

root@focal:~# dpkg -l|grep chardet
ii  python3-chardet 3.0.4-4build1                     all          universal character encoding detector for Python3

And looking at the installed versions in Python's own package manager (pip):

root@focal:~# pip3 list|grep urllib
urllib3                1.26.6   

root@focal:~# pip3 list|grep chardet
chardet                3.0.4 

Alright, this now gives the idea, that the problem is happening because of the urllib3 package. The versions from Ubuntu package (1.25.8) differs from the PIP installed version (1.26.6). The latter is also the mentioned version in the plugin output.

However when removing the older urllib3 package using apt, something interesting happens then:

root@focal:~# apt-get remove python3-urllib3

root@focal:~# /usr/lib/nagios/plugins/check_esxi_hardware.py -H esxiserver -U root -P "secret" -V hp
Traceback (most recent call last):
  File "/usr/lib/nagios/plugins/check_esxi_hardware.py", line 287, in <module>
    import pywbem
  File "/usr/local/lib/python3.8/dist-packages/pywbem/__init__.py", line 49, in <module>
    from ._cim_operations import *  # noqa: F403,F401
  File "/usr/local/lib/python3.8/dist-packages/pywbem/_cim_operations.py", line 143, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Now the plugin doesn't work anymore, instead an error "No module named requests" is mentioned!

Let's install this using pip3:

root@focal:~# pip3 install requests

And the plugin runs fine again, without any dependency warnings:

root@focal:~# /usr/lib/nagios/plugins/check_esxi_hardware.py -H esxiserver -U root -P "secret" -V hp
OK - Server: Cisco Systems Inc UCSC-C220-M5SX s/n: XXXXXXXXX Chassis S/N: XXXXXXXXX  System BIOS: C220M5.4.0.4c.0.0506190754 2019-05-06

Does it hurt to re-install the python3-urllib3 package again? Not really:

root@focal:~# apt-get install python3-urllib3

root@focal:~# /usr/lib/nagios/plugins/check_esxi_hardware.py -H esxiserver -U root -P "secret" -V hp
OK - Server: Cisco Systems Inc UCSC-C220-M5SX s/n: XXXXXXXXX Chassis S/N: XXXXXXXXX  System BIOS: C220M5.4.0.4c.0.0506190754 2019-05-06

So the problem was really because the "requests" python module needed to be installed additionally. It's kind of tricky to see this from the initial warnings though.



Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.