NuX*_*X_o 27 python pip urllib3 chardet python-requests
我找到了几个关于这个问题的网页,但没有一个解决了我的问题.
即使我做了:
pip show
Run Code Online (Sandbox Code Playgroud)
我明白了:
/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
Run Code Online (Sandbox Code Playgroud)
我做了什么 :
pip install --upgrade chardet
Run Code Online (Sandbox Code Playgroud)
但作为解释,它给了我同样的错误.
所以我做了 :
sudo apt remove python-chardet
Run Code Online (Sandbox Code Playgroud)
并且取消他所有的家属.我重新安装后 - >相同:'(
我为python-pip做了同样的事情.重新安装后 - >相同.
以下是关于需要urllib3和chardet的版本线:中/usr/local/lib/python2.7/dist-packages/requests/提取初始化的.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)
Run Code Online (Sandbox Code Playgroud)
我的版本是:
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
Run Code Online (Sandbox Code Playgroud)
我没有更多的想法......
谢谢大家,对不起我的英语:)
Joe*_*hew 48
这是因为操作系统安装了不同的请求模块以及本地安装的python依赖项.
它可以通过升级请求来解决:
pip install requests
Run Code Online (Sandbox Code Playgroud)
要么
pip3 install requests
Run Code Online (Sandbox Code Playgroud)
Ale*_* C. 10
你有一个混合的设置(包括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软件包
来自python-chardet 2.3.0-1的debian软件包chardet(2.3.0)
两种选择:
可以requests从OS发行版降级到该版本(请参阅apt show python-requests参考资料),也可以从pypi.org 降级到较旧的版本,或者
或pip install在用户级别(--userpip安装选项)或在virtualenv中安装较新的urllib3和chardet(您可以从pipy.org手动下载wheel文件并对其进行处理,包括所有依赖项)。
您可以在virtualenv(apt show python-virtualenv)中测试所有内容。它甚至应该在其虚拟环境中为您部署更新的点子。也可以在用户级别(--user)上安装新的pip 10.0.1,并与操作系统提供的pip一起安装,但是您需要注意这一点。祝好运!
升级到时遇到类似的错误urllib3 1.23。安装旧版本可以1.22为我解决此错误。
请按照以下步骤安装旧urllib3版本:
pip uninstall urllib3pip install urllib3==1.22我docker-compose <some-action>在系统更新后尝试运行时遇到了这个问题。
有几个原因可能导致上述错误。
我会在这里添加另一个解决方案,如果其他解决方案不适合他的特定场景,它可能会对某人有所帮助。
以下组合为我解决了这个问题:
pip uninstall urllib3
pip uninstall chardet
pip install requests
Run Code Online (Sandbox Code Playgroud)
对我来说,修复是:
pip uninstall urllib3
pip uninstall chardet
pip install requests
Run Code Online (Sandbox Code Playgroud)
堆:
Centos 7.6.1810
docker-compose 1.24.1 build 4667896(docker-compose 日志给我警告)
蟒蛇 2.7.5
点 8.1.2
小智 5
它为我工作。只需执行以下命令。
$ sudo pip uninstall requests
$ sudo pip install requests
$ sudo pip uninstall docopt
$ sudo pip install docopt
Run Code Online (Sandbox Code Playgroud)
小智 5
所需要的只是sudo pip install --upgrade requests.
如果没有 sudo 你会得到Permission denied,\n如果你添加--user它不会安装到系统 python 中。
此后,pip list不会收到 RequestsDependencyWarning。
我的系统上的输出:
\n\n$ sudo pip install --upgrade requests\n\n/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!\n RequestsDependencyWarning)\nCollecting requests\n Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)\n |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 61kB 510kB/s\nRequirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /usr/lib/python3.7/site-packages (from requests) (2.8)\nRequirement 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)\nCollecting certifi>=2017.4.17 (from requests)\n Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)\n |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 163kB 1.1MB/s\nRequirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.7/site-packages (from requests) (3.0.4)\nInstalling collected packages: certifi, requests\n Found existing installation: requests 2.21.0\n Uninstalling requests-2.21.0:\n Successfully uninstalled requests-2.21.0\nSuccessfully installed certifi-2019.3.9 requests-2.22.0\nRun Code Online (Sandbox Code Playgroud)\n\n[我只是在 @h3xStream 的答案上添加了一条小评论,\n但没有足够的声誉。]
\n就我而言,chardet 包有问题。我安装了两个版本(2.3.0 和 3.04),并且由于某种原因 python 加载了旧版本。我的解决方案是手动删除包:
rm -rf /usr/lib/python2.7/site-packages/chardet*
Run Code Online (Sandbox Code Playgroud)
并再次安装
pip install chardet
Run Code Online (Sandbox Code Playgroud)
如果尚未完成,请更新 urllib3 并请求最新版本
pip install --upgrade urllib3
pip install --upgrade requests
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
32261 次 |
| 最近记录: |