Homebrew's pip3 shortcut via `pip` has hard-coded version dependency causing errors


So I have the python (python3 to be precise) package installed and with it Homebrew created the shortcut for pip3 at /usr/local/opt/python/libexec/bin/pip:

# EASY-INSTALL-ENTRY-SCRIPT: 'pip==19.0.3','console_scripts','pip3'
__requires__ = 'pip==19.0.3'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
        load_entry_point('pip==19.0.3', 'console_scripts', 'pip3')()

This file has stuff about pip’s version (e.g. __requires__ = 'pip==19.0.3') and I think this is causing problems when I upgrade pip3 (using pip install -U pip). Specifically, I run pip install -U pip and this works fine. The command pip3 works with the new version of pip, but when I use pip instead I get the following error:

Traceback (most recent ca ll last):
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 583, in _build_master
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 900, in require
needed = self.resolve(parse_requirements(requirements))
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 791, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 19.1.1 (/usr/local/lib/python3.7/site-packages), Requirement.parse(‘pip==19.0.3’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/opt/python/libexec/bin/pip”, line 6, in
from pkg_resources import load_entry_point
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 3191, in
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 3175, in _call_aside
f(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 3204, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 585, in _build_master
return cls._build_from_requirements(requires)
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File “/usr/local/lib/python3.7/site-packages/pkg_resources/init.py”, line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘pip==19.0.3’ distribution was not found and is required by the application

It seems like the shortcut is “expecting” pip version 19.0.3 but cannot find it after upgrading thus throws this error. I couldn’t find any bug like this on the issue tracker but can anyone confirm this happens as well?

1 Like

Can confirm, I see the same issue. The caveats for the python package mention to use pip3, and that still works. brew upgrade python also fixed it for me - until the next pip upgrade I guess…

I confirm this annoying behavior. I opened a new post, with additional information: Pip install –upgrade pip breaks pip when installed with Homebrew.