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

Written by - 4 comments

Published on - last updated on February 15th 2022 - 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.

Already have requests installed with pip3?

I ran into the very same issue again, while working on a new python script:

$ python3 check_shelly.py -H 10.10.10.50 -t meter
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.4) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
SHELLY OK: Device (shellypro4pm-XXXXXXXXXXXX at 10.10.10.50) SWITCH_0, currently using 321 Watt / 1 Amp |power=321 current=1

But in this situation requests was already installed through pip3:

$ sudo pip3 list | grep requests
requests                 2.22.0 
requests-file            1.4.3               
requests-unixsocket      0.2.0 

In this case try to upgrade the requests package with pip3:

$ sudo pip3 install --upgrade requests
Collecting requests
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
Requirement already satisfied, skipping upgrade: idna<4,>=2.5; python_version >= "3" in /usr/lib/python3/dist-packages (from requests) (2.8)
Collecting charset-normalizer~=2.0.0; python_version >= "3"
  Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests) (2019.11.28)
Requirement already satisfied, skipping upgrade: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests) (1.26.4)
Installing collected packages: charset-normalizer, requests
  Attempting uninstall: requests
    Found existing installation: requests 2.22.0
    Not uninstalling requests at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'requests'. No files were found to uninstall.
Successfully installed charset-normalizer-2.0.12 requests-2.27.1

Now the warnings are gone:

$ python3 check_shelly.py -H 10.10.10.50 -t meter
SHELLY OK: Device (shellypro4pm-XXXXXXXXXXXX at 10.10.10.50) SWITCH_0, currently using 312 Watt / 1 Amp |power=312 current=1



Add a comment

Show form to leave a comment

Comments (newest first)

Pablo Nehuen from Argentina wrote on Dec 24th, 2022:

Thaks. It was really helpfull


MintDaemon from wrote on May 26th, 2022:

I was stuck on this issue for hours before I came across your blog. This was of tremendous help,Thanks!


José Santos from México, Mty, NL wrote on Mar 7th, 2022:

Great,its helps me to solves also another python app problem. Thanks a lot.


Bas from wrote on Jan 25th, 2022:

Thanks a lot! It was an annoying error. Too bad awsebcli requires the older version of requests. :(


RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder