Pip --version not working on my macos mojave anymore, how to fix it?

Hi,

I installed python using brew command. And before i could use both pip --version, and pip3 --version. I saw that i had previous version of pip. I ran the command pip install --upgrade pip. When i run python --version its how me the version. When i run pip3 --version i get this:

pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

But when i run pip --version , its gives me error:

pip --version
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  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.2.3 (/usr/local/lib/python3.7/site-packages), Requirement.parse('pip==19.1.1'))

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 <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3241, in <module>
    @_call_aside
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3225, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3254, 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.1.1' distribution was not found and is required by the application

How can i fix this? I tried to run brew doctor and tried to find any solution with no luck.

I have this in my zshrc file:
# Python version from Homebrew export PATH="/usr/local/opt/python/libexec/bin:$PATH"

When i type which python i get following: /usr/local/opt/python/libexec/bin/python

Anyone know how to fix this? Thank you:)

does brew reinstall python fix it?

Ah thank you! But now i see that I am back on version 19.1.1.

 ~ python --version
Python 3.7.4
 ~ pip3 --version
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
 ~ pip --version
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

How can i upgrade the pip version to latest which is 19.2.3 ?

I also saw this issue: https://github.com/pypa/pip/issues/6399 , is it anything Homebrew can do to fix this issue?

You should be able to update pip with python3 -m install -U pip

I tried the command, and got following output:
/usr/local/opt/python/bin/python3.7: No module named install

Whoops, sorry:
python3 -m pip install -U pip

Still getting same error when i type pip --version:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  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.2.3 (/usr/local/lib/python3.7/site-packages), Requirement.parse('pip==19.1.1'))

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 <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3241, in <module>
    @_call_aside
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3225, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3254, 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.1.1' distribution was not found and is required by the application

From this link, try and download the get-pip.py with curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py Then run python3 get-pip.py

I guess it is connected to Tickets Pip install --upgrade pip breaks pip when installed with Homebrew and Homebrew's pip3 shortcut via `pip` has hard-coded version dependency causing errors.

Actually, it has little to do with the Mac. It is due to an inconsistency between the respective conventions of Homebrew and Python/Pip in installing pip. It has been signaled to the respective maintainers, but no corrective action could be made, yet.

An easy fix is to adjust the symbolic links by hand. See the above tickets for details.

Luc.