How to fix urllib3 RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22?

元气小坏坏 提交于 2019-12-22 10:55:11

问题


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

and

sudo apt-get upgrade

to get everything up to date.

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')

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!

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!

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?

Thank you very much.


回答1:


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



来源:https://stackoverflow.com/questions/44397101/how-to-fix-urllib3-runtimeerror-requests-dependency-urllib3-must-be-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!