pkg_resources.DistributionNotFound: The 'urllib3<1.23,>=1.21.1'

On an update to v11 I encountered this

(env) frappe@ubuntu:~/frappe-bench$ bench update
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3195, in <module>
    @_call_aside
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3179, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3208, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 683, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 696, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 885, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'urllib3<1.23,>=1.21.1' distribution was not found and is required by requests

Fixed with this:

pip uninstall urllib3
pip uninstall requests
pip uninstall chardet

pip install --upgrade --force-reinstall ‘requests==2.6.0’ urllib3

From this reference pkg_resources.DistributionNotFound: The 'urllib3<1.23,>=1.21.1' distribution was not found and is required by requests · Issue #5465 · certbot/certbot · GitHub

I had to use sudo to overcome this OSError: [Errno 13] Permission denied: ‘/usr/local/lib/python2.7/dist-packages/requests’

That may indicate my environment is not healthy

edit:

frappe@ubuntu:~/frappe-bench$ pip --help | grep freeze
  freeze                      Output installed packages in requirements format.
frappe@ubuntu:~/frappe-bench$ pip freeze | grep urllib
You are using pip version 9.0.3, however version 19.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
urllib3==1.24.1
1 Like

I had to do exactly the same in an update… finally got it to work.:muscle:

+1 this solution

Excellent, the lib change seems reasonable - certbot is the tool LetsEncrypt uses to issue SSL certificates.

1 Like