RequestsDependencyWarning:urllib3 (1.25.2) 或 chardet (3.0.4) 与支持的版本不匹配!修复

问题描述 投票:0回答:8

每当我使用请求运行代码或进行 pip 安装时,我都会收到此消息

/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)

我尝试升级 chardet、urllib3 和 requests,但没有任何效果,有人知道我该如何解决这个问题吗?

编辑:RequestsDependencyWarning:urllib3(1.9.1)或chardet(2.3.0)与支持的版本不匹配<-- This did not fix my problem.

python pip importerror archlinux
8个回答
287
投票

解决此问题的正确命令是:

pip3 install --upgrade requests

我从

2.21.0
升级到
2.24.0
,错误消失了。


65
投票

您只需安装最新版本的requests

  pip3 install requests

22
投票

我解决了这个问题

pip install --upgrade requests==2.20.1

如果您看到如下所示的版本不兼容消息,您应该尝试其他版本。所有版本均为:这里

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.

5
投票

当我尝试运行 docker-compose 时遇到这个问题: urllib3 (1.24.1) 或 chardet (3.0.4) 与支持的版本不匹配

就我而言,我通过删除 docker-compose 来解决:

sudo apt-get remove docker-compose

并安装:

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

编辑: 现在它应该包含

v
来指定其版本。

sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

然后运行:

sudo chmod +x /usr/local/bin/docker-compose


4
投票

找到这个并查看 requests/init.py 源文件:

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    !HERE!
        assert major == 3
        assert minor < 1
        assert patch >= 2

2
投票

就我而言,升级请求不起作用。

pip3 install requests

我使用了ehh的解决方案再次下载docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose

然后通过以下方式向文件添加执行能力

sudo chmod +x /usr/bin/docker-compose


0
投票

我遇到了同样的问题,并使用命令解决了这个问题

pip install --升级请求==2.20.1


0
投票

这对我有用 pip3 install --upgrade requests

© www.soinside.com 2019 - 2024. All rights reserved.