我找到了几个关于这个问题的网页,但没有一个解决了我的问题。
即使我做了:
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做了同样的事情。重新安装后 - >相同。
以下是有关urllib3和chardet版本的行:/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
我没有更多的想法......
谢谢大家,对不起我的英语:)
你确实有一个混合设置(apt
和pip
都用于安装系统范围,这很常见),它确实与请求所需的模块支持版本不匹配(并且pip v1.5.6也很老) 。
requests
(哪个版本?可能来自pip install
)可能需要:
urllib3:1.21.1 - 1.22
chardet:3.0.2 - 3.1.0
你有: 来自python-urllib3的urllib3(1.9.1)1.9.1-3 debian包 chardet(2.3.0)来自python-chardet 2.3.0-1 debian包
两种选择:
requests
降级到您的操作系统发行版中的版本(请参阅apt show python-requests
提供的版本),要么将旧版本降级到pypi.org,或者pip install
,包括任何依赖项),可以在用户级别(--user
pip install选项)或virtualenv中。你可以用virtualenv(apt show python-virtualenv
)测试一切。它甚至应该在其虚拟环境中为你部署一个更新的点。 possible也是在用户级别(--user
)安装一个新的pip 10.0.1以及你的OS销售点,但你需要成为careful。祝好运!
所需要的只是sudo pip install --upgrade requests
。
没有sudo你会得到Permission denied
,如果你添加--user
它将不会安装到系统python中。
在此之后,pip list
没有获得RequestsDependencyWarning。
我系统上的输出:
$ 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
[我会简单地在@ h3xStream的答案上添加一个小评论,但没有足够的声誉。]
试图将urllib3降级1.25.2降至1.24.3,但未找到后者。
$ sudo pip install -I urllb3==1.24.3
ERROR: No matching distribution found for urllb3==1.24.3
一个对我有用的快速修复:编辑/usr/lib/python3.7/site-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.24
assert major == 1
assert minor >= 21
assert minor <= 24
改变了assert minor <= 24
到assert minor <= 25
,这解决了我的问题 - 现在。
有关于Github https://github.com/streamlink/streamlink/issues/2448的错误报告
只需更新pip:sudo pip install -U pip
这是因为操作系统安装了不同的请求模块以及本地安装的python依赖项。
它可以通过升级请求来解决:
pip install requests
要么
pip3 install requests
它对我有用。只需执行以下命令。
$ sudo pip uninstall requests
$ sudo pip install requests
$ sudo pip uninstall docopt
$ sudo pip install docopt
这是参考link for detail!
升级到urllib3 1.23
时面临类似的错误。旧版1.22
的安装为我解决了这个错误。
是否安装了较旧的urllib3
版本:
pip uninstall urllib3
pip install urllib3==1.22
最佳做法是确保请求及其依赖关系是最新的。
Python 2
$ pip install --upgrade requests
Python 3
$ pip3 install --upgrade requests
我有一个旧版本的requests
。
将requests
版本从2.19.1
改为2.20.1
解决了它。
在任何时候,检查源是这样的,特别是当开发人员在评论中留下明确的指令时,就像在这种情况下一样。 (也许作者应该更具体,并把它放在错误信息中,是的)
打开vi /usr/lib/python2.7/site-packages/requests/__init__.py
并搜索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
然后,您知道urllib3
和chardet
兼容的版本范围。所以,你尝试:
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
在系统更新后尝试运行docker-compose <some-action>
时遇到此问题。
有几个原因可能导致提到的错误。
我会在这里添加另一个解决方案,如果其他解决方案不符合他的特定情况,它可能会对某人有所帮助。
以下组合为我解决了这个问题:
pip uninstall urllib3
pip uninstall chardet
pip install requests
很简单,你只需要更新 -
pip3 install requests