Python (pip) - RequestsDependencyWarning: urllib3 (1.9.1) 或 chardet (2.3.0) 与支持的版本不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50202238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python (pip) - RequestsDependencyWarning: urllib3 (1.9.1) or chardet (2.3.0) doesn't match a supported version
提问by NuX_o
I found several pages about this issue but none of them solved my problem.
我找到了几个关于这个问题的页面,但没有一个解决了我的问题。
Even if I do a :
即使我做了一个:
pip show
I get :
我得到:
/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
What I did :
我做了什么 :
pip install --upgrade chardet
but as explain up, it gaves me the same error.
但作为解释,它给了我同样的错误。
so I did :
所以我做了 :
sudo apt remove python-chardet
and unistalling all his dependecies. After I reinstall it -> the same :'(
并解除他所有的依赖。在我重新安装它之后-> 相同:'(
I did the same for python-pip
. After reinstalling it -> the same.
Here are the lines about urllib3
and chardet
versions needed :
extract of /usr/local/lib/python2.7/dist-packages/requests/__init__.py
:
我对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)
My versions are :
我的版本是:
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
I don't have no more ideas...
我没有更多的想法...
Thanks to you all and sorry for my english :)
谢谢大家,对不起我的英语:)
采纳答案by Alex C.
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).
你有一个混合的设置(包括apt
和pip
用来安装系统范围内,这是常见的),它确实不匹配,请求所需模块的支持版本(和PIP v1.5.6也相当大)。
The requests
(which version? likely leftover from pip install
) requires:
urllib3: 1.21.1 - 1.22
chardet: 3.0.2 - 3.1.0
在requests
(?哪个版本可能从剩下的pip install
)要求:
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
你有:
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 withapt show python-requests
), or older versions at pypi.org, oror 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.
requests
从您的操作系统发行版降级到版本(查看apt show python-requests
pypi.org 上的可用版本)或旧版本,或或者
pip install
在用户级别(--user
pip install 选项)或在 virtualenv 中安装更新的 urllib3 和 chardet(您可以从 pipy.org 手动下载轮文件并对其进行处理,包括任何依赖项)。
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 possibleto install a newer pip 10.0.1 at the user-level (--user
) alongside your OS-vendored pip but you need to be carefulabout that. Good luck!
您可以在virtualenv( apt show python-virtualenv
) 中测试所有内容。它甚至应该在其虚拟环境中为您部署一个更新的 pip。也可以在用户级别 ( --user
) 与操作系统供应商的 pip 一起安装更新的 pip 10.0.1,但您需要注意这一点。祝你好运!
回答by Joel G Mathew
This is because of different requests module installed by the OS and the python dependencies for your local installation.
这是因为操作系统安装了不同的请求模块以及本地安装的 python 依赖项。
It can be solved by upgrading requests:
可以通过升级请求来解决:
pip install requests
or
或者
pip3 install requests
回答by Nafeez Quraishi
Faced similar error when upgraded to urllib3 1.23
. Installation of older version 1.22
resolved this error for me.
升级到urllib3 1.23
. 旧版本的安装1.22
为我解决了这个错误。
Did following to install the older urllib3
version:
执行以下操作来安装旧urllib3
版本:
pip uninstall urllib3
pip install urllib3==1.22
pip uninstall urllib3
pip install urllib3==1.22
回答by h3xStream
The best practice would be to make sure requests and its dependenciesare up to date.
最佳实践是确保请求及其依赖项是最新的。
Python 2
蟒蛇 2
$ pip install --upgrade requests
$ pip install --upgrade 请求
Python 3
蟒蛇 3
$ pip3 install --upgrade requests
$ pip3 install --upgrade 请求
回答by 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!
回答by RtmY
I encountered this issue when trying to run docker-compose <some-action>
after a system update.
我docker-compose <some-action>
在系统更新后尝试运行时遇到了这个问题。
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
回答by Mohammad Aarif
Simple you have to update only -
简单你只需要更新 -
pip3 install requests
回答by TawHK
For me the fix was:
对我来说,修复是:
pip uninstall urllib3
pip uninstall chardet
pip install requests
Stack:
堆:
Centos 7.6.1810
Centos 7.6.1810
docker-compose 1.24.1 build 4667896 (docker-compose logs give me the warn)
docker-compose 1.24.1 build 4667896(docker-compose 日志给我警告)
python 2.7.5
蟒蛇 2.7.5
pip 8.1.2
点 8.1.2
回答by j77h
All that's needed is sudo pip install --upgrade requests
.
所需要的只是sudo pip install --upgrade requests
.
Without sudo you'll get Permission denied
,
and if you add --user
it won't install into system python.
没有 sudo 你会得到Permission denied
,如果你添加--user
它就不会安装到系统 python 中。
After this, pip list
does not get a RequestsDependencyWarning.
在此之后,pip list
不会得到 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.]
[我会简单地对@h3xStream 的回答添加一个小评论,但没有足够的声誉。]
回答by Eyal Levin
I had an older version of requests
.
我有一个旧版本的requests
.
Changing requests
version from 2.19.1
to 2.20.1
solved it for me.
更改requests
从版本2.19.1
以2.20.1
解决对我来说。