RequestsDependencyWarning: urllib3 (1.9.1) or chardet (2.3.0) doesn't match a supported version

梦想与她 提交于 2019-12-01 02:08:58

You do have a mixed setup (both apt and pip were used to install system-wide, which is common), and it indeed doesn't match the supported versions of modules required by requests (and pip v1.5.6 is also quite old).

The requests (which version? likely leftover from pip install) requires:
urllib3: 1.21.1 - 1.22
chardet: 3.0.2 - 3.1.0

You have:
urllib3 (1.9.1) from python-urllib3 1.9.1-3 debian package
chardet (2.3.0) from python-chardet 2.3.0-1 debian package

Two options:

  • either downgrade requests to the version from your OS distribution (see what's available with apt show python-requests), or older versions at pypi.org, or

  • or install newer urllib3 and chardet (you can download the wheel files manually from pipy.org and do pip install on them, including any dependencies), either at user level (--user pip install option) or in a virtualenv.

You can test everything in a virtualenv (apt show python-virtualenv). It should even deploy a newer pip for you inside of its virtual envs. It is also possible to install a newer pip 10.0.1 at the user-level (--user) alongside your OS-vendored pip but you need to be careful about that. Good luck!

This is because of different requests module installed by the OS and the python dependencies for your local installation.

It can be solved by upgrading requests:

pip install requests

or

pip3 install requests

Faced similar error when upgraded to urllib3 1.23. Installation of older version 1.22 resolved this error for me.

Did following to install the older urllib3 version:

  1. pip uninstall urllib3
  2. pip install urllib3==1.22
Saurabh

It worked for me. Simply execute below commands.

$ sudo pip uninstall requests

$ sudo pip install requests

$ sudo pip uninstall docopt

$ sudo pip install docopt

Here's the reference link for detail!

The best practice would be to make sure requests and its dependencies are up to date.

Python 2

$ pip install --upgrade requests

Python 3

$ pip3 install --upgrade requests

Simple you have to update only -

 pip3 install requests

I encountered this issue when trying to run docker-compose <some-action> after a system update.

There are a few reasons that can lead to the error mentioned.

I'll add another solution here, maybe it will help somebody if the other solutions doesn't fit his specific scenario.

The following combination solved the problem for me:

pip uninstall urllib3    
pip uninstall chardet
pip install requests 

I had an older version of requests.

Changing requests version from 2.19.1 to 2.20.1 solved it for me.

At any moment, check the source is the way, specially when the developer has left clear instruction in the comments, like in this case. (Maybe the author should be more specific and put it in the error message, yes)

Open vi /usr/lib/python2.7/site-packages/requests/__init__.py and search for check_compatibility(.

def check_compatibility(urllib3_version, chardet_version):
    urllib3_version = urllib3_version.split('.')
    assert urllib3_version != ['dev']  # Verify urllib3 isn't installed from git.

    # Sometimes, urllib3 only reports its version as 16.1.
    if len(urllib3_version) == 2:
        urllib3_version.append('0')

    # Check urllib3 for compatibility.
    major, minor, patch = urllib3_version  # noqa: F811
    major, minor, patch = int(major), int(minor), int(patch)
    # urllib3 >= 1.21.1, <= 1.24     <------------------ here
    assert major == 1
    assert minor >= 21
    assert minor <= 24

    # Check chardet for compatibility.
    major, minor, patch = chardet_version.split('.')[:3]
    major, minor, patch = int(major), int(minor), int(patch)
    # chardet >= 3.0.2, < 3.1.0     <------------------ and here
    assert major == 3
    assert minor < 1
    assert patch >= 2

Then, you know the range of versions of urllib3 and chardet compatible. So, you try with:

pip uninstall urllib3
pip install urllib3==1.24
pip uninstall chardet
pip install chardet==3.0.9 # this will fail, prompting the correct versions available, so you will try to install 3.0.4 instead

All that's needed is sudo pip install --upgrade requests.

Without sudo you'll get Permission denied, and if you add --user it won't install into system python.

After this, pip list does not get a RequestsDependencyWarning.

The output on my system:

$ sudo pip install --upgrade requests

/usr/lib/python3.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Collecting requests
  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
     |████████████████████████████████| 61kB 510kB/s
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /usr/lib/python3.7/site-packages (from requests) (2.8)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python3.7/site-packages (from requests) (1.25.2)
Collecting certifi>=2017.4.17 (from requests)
  Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
     |████████████████████████████████| 163kB 1.1MB/s
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.7/site-packages (from requests) (3.0.4)
Installing collected packages: certifi, requests
  Found existing installation: requests 2.21.0
    Uninstalling requests-2.21.0:
      Successfully uninstalled requests-2.21.0
Successfully installed certifi-2019.3.9 requests-2.22.0

[I would have simply added a small comment on @h3xStream's answer, but don't have enough reputation.]

Tried to downgrade urllib3 1.25.2 to 1.24.3, but latter was not found.

$ sudo pip install -I urllb3==1.24.3
ERROR: No matching distribution found for urllb3==1.24.3

A quick fix that worked for me: Edit /usr/lib/python3.7/site-packages/requests/__init__.py

In the block:

# Check urllib3 for compatibility.
major, minor, patch = urllib3_version  # noqa: F811
major, minor, patch = int(major), int(minor), int(patch)
# urllib3 >= 1.21.1, <= 1.24     
assert major == 1
assert minor >= 21
assert minor <= 24

Changed the assert minor <= 24 to assert minor <= 25 and this solved my issue - for now.

There's a bug report on Github https://github.com/streamlink/streamlink/issues/2448

just update pip: sudo pip install -U pip

I got this error running a virtual python environment (Home Assistant) and the above suggestions didn't work for me since the user (homeassistant) didn't have a password or sudo rights.

The solution in this scenario was to simply deactivate the venv environment and then delete the virtual environment directory and recreate the virtual folder.

To deactivate the python3 venv, simple execute the 'deactivate' bash command anywhere inside your virtual environment tree.

I fixed this problem with

pip install --upgrade requests==2.20.1

If you see version incompatible message like following, you should try other versions. All versions are: here

ERROR: docker-compose 1.24.1 has requirement requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1, but you'll have requests 2.21.0 which is incompatible.

I fixed this problem with this command

pip install --upgrade requests==2.20.1

If you see version incompatible message like following, you should try other versions. All versions are: here

ERROR: docker-compose 1.24.1 has requirement requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1, but you'll have requests 2.21.0 which is incompatible.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!