RequestsDependencyWarning: urllib3

One day I was running an Ansible Ad-hoc command on my system for testing purposes, suddenly a python related error popped up from nowhere. At first, I thought it gonna chase me till the laptop battery gets drained out of juice.

The error I get in the command prompt is documented below.

$ ansible web -m command -a "w"
/usr/lib/python3.6/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.11) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)

At first, I got totally confused about how did this error came into my system, then I got some idea about past sessions with my systems, I did try to install the following packages. I got these commands from history.

  318  sudo apt install python
  319  sudo apt install python-pip
  320  pip install boto boto3 ansible
  321  sudo yum install python
  322  sudo yum install python36
  323  sudo yum install python-pip

someone from these 6 operations caused the error, so I just tried the same old story, Googled the error.

And the first GitHub post comes to the rescue, I got a result for the exact fix for the issue.

The fix was simple but it was effective, the command and its output is mentioned below.

$ pip install --upgrade requests
Defaulting to user installation because normal site-packages is not writeable
Collecting requests
  Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 635 kB/s
Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /usr/lib/python3.6/site-packages (from requests) (3.0.4)
Collecting certifi>=2017.4.17
  Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
     |████████████████████████████████| 156 kB 8.4 MB/s
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./.local/lib/python3.6/site-packages (from requests) (1.25.11)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /usr/lib/python3.6/site-packages (from requests) (2.5)
Installing collected packages: certifi, requests
Successfully installed certifi-2020.6.20 requests-2.24.0

Once after the command run successfully, I give a try for the same Ansible - Ad hoc Command and this time everything worked well without any errors.

$ ansible web -m ping
node1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}
node2 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}

I recommend reviewing the Github post for a better understanding cause for the error.

THE END (^_^)