Python(pip)-RequestsDependencyWarning:urllib3(1.9.1)或chardet(2.3.0)与支持的版本不匹配 - python

我找到了关于此问题的几页,但没有一个解决了我的问题。

即使我做了:

pip show

我得到:

/usr/local/lib/python2.7/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.9.1) or chardet (2.3.0) doesn't match a supported version!
  RequestsDependencyWarning)
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 480, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2691, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2322, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2328, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
    import requests, six
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 90, in <module>
    from urllib3.exceptions import DependencyWarning
ImportError: cannot import name DependencyWarning

我做了什么 :

pip install --upgrade chardet

但据解释,它给了我同样的错误。

所以我做了 :

sudo apt remove python-chardet

并毫不动摇地依靠他
重新安装后->相同:'(

我对python-pip也做了同样的事情。重新安装后->相同。
以下是有关urllib3chardet版本的行:/usr/local/lib/python2.7/dist-packages/requests/__init__.py的摘录:

    # 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.22
    assert major == 1
    assert minor >= 21
    assert minor <= 22

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


# Check imported dependencies for compatibility.
try:
    check_compatibility(urllib3.__version__, chardet.__version__)
except (AssertionError, ValueError):
    warnings.warn("urllib3 ({0}) or chardet ({1}) doesn't match a supported "
                  "version!".format(urllib3.__version__, chardet.__version__),
                  RequestsDependencyWarning)

我的版本是:

ii  python-urllib3 1.9.1-3   all HTTP library with thread-safe connection pooling for Python 
ii  python-chardet  2.3.0-1  all universal character encoding detector for Python2

我没有别的主意了...

谢谢大家,对不起我的英语:)

参考方案

您确实有一个混合设置(aptpip都用于在系统范围内安装,这很常见),并且确实与请求所需的受支持模块版本不匹配(并且pip v1.5.6也已经很老了) 。
requests(哪个版本?可能是pip install的剩余版本)要求:
urllib3:1.21.1-1.22
字符:3.0.2-3.1.0

你有:
python-urllib3 1.9.1-3 debian软件包中的urllib3(1.9.1)
python-chardet 2.3.0-1 debian软件包中的chardet(2.3.0)

两种选择:

  • 可以将requests降级为OS发行版中的版本(请参阅apt show python-requests的可用版本),也可以将其降级到pypi.org或
  • 或在用户级别(pip install pip install选项)或在virtualenv中安装较新的urllib3和chardet(您可以从pipy.org手动下载wheel文件并对其进行--user,包括任何依赖项)。
  • 您可以在virtualenv(apt show python-virtualenv)中测试所有内容。它甚至应该在其虚拟环境中为您部署更新的点子。在用户级别(--user)上安装新的pip 10.0.1以及您的操作系统提供的pip也是possible,但是您需要为此careful。祝好运!

    找不到满足python要求的版本 - python

    我试图从here在macOS中使用python2创建虚拟环境。在终端中运行pip install virtualenv命令时,出现以下错误。Could not find a version that satisfies the requirement virtualenv (from versions: ) No matching distribution …

    Python GPU资源利用 - python

    我有一个Python脚本在某些深度学习模型上运行推理。有什么办法可以找出GPU资源的利用率水平?例如,使用着色器,float16乘法器等。我似乎在网上找不到太多有关这些GPU资源的文档。谢谢! 参考方案 您可以尝试在像Renderdoc这样的GPU分析器中运行pyxthon应用程序。它将分析您的跑步情况。您将能够获得有关已使用资源,已用缓冲区,不同渲染状态上…

    Python:图像处理可产生皱纹纸效果 - python

    也许很难描述我的问题。我正在寻找Python中的算法,以在带有某些文本的白色图像上创建皱纹纸效果。我的第一个尝试是在带有文字的图像上添加一些真实的皱纹纸图像(具有透明度)。看起来不错,但副作用是文本没有真正起皱。所以我正在寻找更好的解决方案,有什么想法吗?谢谢 参考方案 除了使用透明性之外,假设您有两张相同尺寸的图像,一张在皱纹纸上明亮,一张在白色背景上有深…

    尝试通过pip安装cProfile,但出现错误 - python

    Closed. This question is not reproducible or was caused by typos。它当前不接受答案。 想改善这个问题吗?更新问题,以使溢出。 去年关闭。 on-topic 因此,我到处四处寻找有关如何安装cProfile的帮助,但没有发现任何问题。这种情况通常发生时,我转向pip并运行通常的命令:'pip in…

    Python uuid4,如何限制唯一字符的长度 - python

    在Python中,我正在使用uuid4()方法创建唯一的字符集。但是我找不到将其限制为10或8个字符的方法。有什么办法吗?uuid4()ffc69c1b-9d87-4c19-8dac-c09ca857e3fc谢谢。 参考方案 尝试:x = uuid4() str(x)[:8] 输出:"ffc69c1b" Is there a way to…