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

1

5

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.

Borosilicate answered 6/6, 2017 at 18:17 Comment(8)
What if you upgrade Python? 3.4 is not the latestDisorganize
ran sudo apt-get upgrade python in the bash shell and it is up to date.Borosilicate
Python 3.6 is public since December.Chokedamp
I'm trying to find the proper bash command to install the most recent version of python but I'm seeing a lot of different things. I assume it's some version of sudo apt-get install but when I type sudo apt-get install python3.6 I get an error saying the package could not be located.Borosilicate
It may not be public in the Rasbian repo, but you can install berryconda. github.com/jjhelmus/berrycondaDisorganize
Also. raspberrypi.stackexchange.com/questions/59381/…Disorganize
Tried installing Python 3.6 with BerryConda and still no luck. I'm seeing a lot of other issues people are having within the past week or so regarding urllib3 so I'm wondering if there may be an issue there. At any rate, it looks like my efforts to upload a file to dropbox have be thwarted for now.Borosilicate
Okay, interesting note on environment here: I did a fresh install of Debian. When I imported the twilio module my text messaging scripts ran just fine. After imported the dropbox module (using sudo pip3 install dropbox) neither the dropbox upload scripts nor the twilio SMS scripts work. So it seems something with the dropbox module for python may be causing the error with urllib3? I have absolutely no idea. I'm just trying to remove individual variables and spot whats causing the issue.Borosilicate
H
4

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

Harlem answered 30/10, 2018 at 20:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.