如何修复urllib3 RuntimeError:请求依赖项"urllib3"的版本必须> = 1.21.1,< 1.22? [英] How to fix urllib3 RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22?

查看:1185
本文介绍了如何修复urllib3 RuntimeError:请求依赖项"urllib3"的版本必须> = 1.21.1,< 1.22?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名新开发人员,正在学习使用Python 3.4.2进行编码.我在Raspberry Pi3上运行Debian linux.全新安装后,我都做了

I am a new developer and learning to code in Python 3.4.2. I am running Debian linux on a Raspberry Pi3. After the fresh install I did both

sudo apt-get update

sudo apt-get upgrade

使所有内容保持最新状态.

to get everything up to date.

我正在尝试测试将文件上传到Dropbox的一段代码:

I am trying to test a section of code which uploads a file to Dropbox:

import dropbox
import urllib3

authkey = (my dropbox dev auth key)

with open('test.csv','rb') as f:
    dbx = dropbox.Dropbox(authkey)
    dbx.files_upload(f.read(), '/test.csv')

现在,我不知道实际的Dropbox代码是否正确,因为在Python shell中运行脚本时出现以下错误:

Now, I have no idea if the actual Dropbox code is correct, because I am getting the following error when I run the script in the Python shell:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
    assert minor >= 21
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/dbtest.py", line 1, in <module>
    import dropbox
  File "/usr/local/lib/python3.4/dist-packages/dropbox/__init__.py", line 3, in <module>
    from .dropbox import __version__, Dropbox, DropboxTeam, create_session  # noqa: F401
  File "/usr/local/lib/python3.4/dist-packages/dropbox/dropbox.py", line 18, in <module>
    import requests
  File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 61, in <module>
    raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

对我来说,这表明我的urllib3安装存在问题,因此我进入了bash shell并输入:

To me this indicates that I have an issue with my urllib3 install, so I go to the bash shell and type:

sudo pip3 install --update urllib3

并获得完全相同的错误消息:

And get the exact same error message:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
    assert minor >= 21
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
    ['__name__'])
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python3/dist-packages/pip/download.py", line 22, in <module>
    import requests, six
  File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 61, in <module>
    raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

我还有其他使用Twilio发送SMS消息的脚本,它们也不再起作用,产生引用urllib3版本问题的相同错误消息.

I have other scripts that use Twilio to send SMS messages and they are no longer working either, yielding the same error message referencing urllib3 version issues.

有人可以帮助我解决此问题或为我指明正确的方向吗?

Can anyone help me resolve this issue or point me in the right direction?

非常感谢您.

推荐答案

在Mac上,请尝试以下操作: sudo pip install urllib3 == 1.23 sudo pip安装请求

On Mac try this : sudo pip install urllib3==1.23 sudo pip install requests

这篇关于如何修复urllib3 RuntimeError:请求依赖项"urllib3"的版本必须&gt; = 1.21.1,&lt; 1.22?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆