Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading pip breaks pip #43867

Closed
5 of 6 tasks
Slooz opened this issue Sep 4, 2019 · 9 comments
Closed
5 of 6 tasks

Upgrading pip breaks pip #43867

Slooz opened this issue Sep 4, 2019 · 9 comments
Labels
outdated PR was locked due to age

Comments

@Slooz
Copy link

Slooz commented Sep 4, 2019

  • are reporting a bug others will be able to reproduce and not asking a question or requesting software. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh. To get software added or changed in Homebrew please file a Pull Request
  • have a problem with brew install (or upgrade, reinstall) a single, Homebrew/homebrew-core formula (not cask) on macOS? If it's a general brew problem please file this issue at Homebrew/brew: https://github.com/Homebrew/brew/issues/new/choose. If it's a Linux problem please file this issue at https://github.com/Homebrew/linuxbrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

See Gist logs.

I'm trying to upgrade pip because it's good to keep your software updated.

After upgrading pip, pip throws an exception:

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

Reproduction instructions:

  1.  $ brew install python
    ==> Downloading https://homebrew.bintray.com/bottles/python-3.7.4.mojave.bottle.tar.gz
    Already downloaded: /Users/Czelusniak_Krzysztof/Library/Caches/Homebrew/downloads/ffcfe300e2ad205387a2bdd27185d98d64621578d26d2f6ccbbcd091ff799fc8--python-3.7.4.mojave.bottle.tar.gz
    ==> Pouring python-3.7.4.mojave.bottle.tar.gz
    ==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.4/bin --install-lib=/usr/local/lib/python3.7/site-packages --single-version-externally-manag
    ==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.4/bin --install-lib=/usr/local/lib/python3.7/site-packages --single-version-externally-manag
    ==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.4/bin --install-lib=/usr/local/lib/python3.7/site-packages --single-version-externally-manag
    ==> Caveats
    Python has been installed as
      /usr/local/bin/python3
    
    Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
    `python3`, `python3-config`, `pip3` etc., respectively, have been installed into
      /usr/local/opt/python/libexec/bin
    
    If you need Homebrew's Python 2.7 run
      brew install python@2
    
    You can install Python packages with
      pip3 install <package>
    They will install into the site-package directory
      /usr/local/lib/python3.7/site-packages
    
    See: https://docs.brew.sh/Homebrew-and-Python
    ==> Summary
    🍺  /usr/local/Cellar/python/3.7.4: 3,865 files, 60MB
  2.  $ python -m pip install --upgrade pip
    Collecting pip
      Using cached https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl
    Installing collected packages: pip
      Found existing installation: pip 19.1.1
        Uninstalling pip-19.1.1:
          Successfully uninstalled pip-19.1.1
    Successfully installed pip-19.2.3
  3.  $ pip
    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

See related links:

@dfkotz
Copy link
Contributor

dfkotz commented Sep 8, 2019

I'm seeing the same issue.

@dfkotz
Copy link
Contributor

dfkotz commented Sep 8, 2019

Either homebrew fixed something, or the following fixed the problem for me.

[MacOS:~]$ sudo -H python3 -m pip install --force-reinstall pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 3.2MB/s 
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-19.2.3
[MacOS:~]$ pip3

Usage:   
  pip3 <command> [options]
...

@Slooz
Copy link
Author

Slooz commented Sep 9, 2019

@dfkotz, one thing to note is that I'm invoking pip, not pip3. I added /usr/local/opt/python/libexec/bin to my path, so invoking pip should invoke pip3.

@dfkotz
Copy link
Contributor

dfkotz commented Sep 9, 2019

I still use python2 sometimes so my pip invokes pip2, and thus I must use pip3 when I mean pip3.

@Slooz
Copy link
Author

Slooz commented Sep 9, 2019

Makes sense, but my point is that /usr/local/opt/python/libexec/bin/pip throws the error that I reported, but it should invoke pip3

@simonweil
Copy link

Same thing happens to me when upgrading pip of python@2...

@CharlyRipp
Copy link

Just ran into this today as well.

pkg_resources.VersionConflict: (pip 19.3 (/usr/local/lib/python3.7/site-packages), Requirement.parse('pip==19.1.1'))

Attempted what worked for @dfkotz (sudo -H python3 -m pip install --force-reinstall pip) but didn't work.

Invoking pip3 however does still function as well as python -m pip.

Ended up reverting, which got tricky for some reason. Had to

brew install python@2
brew uninstall python@3 --ignore-dependencies
sudo rm -rf /usr/local/lib/python3.7
brew install python@3

@sdavids
Copy link

sdavids commented Oct 25, 2019

For the interim a workaround would be to change every occurrence of 19.2.3 with 19.3.1 in file /usr/local/opt/python/libexec/bin/pip:

$ sed -i "" 's/19\.2\.3/19.3.1/' /usr/local/opt/python/libexec/bin/pip

@fxcoudert
Copy link
Member

We have since then upgraded pip in the python formulas

@lock lock bot added the outdated PR was locked due to age label Jan 1, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

6 participants