When I run the pip command, I get an error like pkg_resources.DistributionNotFound: pip == 1.5.4
and can't do anything.
pip install --upgrade pip
brew install python
and then
==> Caveats
Setuptools and Pip have been installed. To update them
pip install --upgrade setuptools
pip install --upgrade pip
However, if I upgrade pip according to this, pip will not work.
/ usr / local / bin / pip
is still out of date even though pip has been upgraded.
You can start pip with python -m pip
. Delete / usr / local / bin / pip
$ rm /usr/local/bin/pip /usr/local/bin/pip2 /usr/local/bin/pip2.7
$ python -m pip install --upgrade --force-reinstall pip
Or
$ python -m pip install --upgrade --force-reinstall pip --no-use-wheel
To do. If you use the latter method, whenever you upgrade pip or setuptools in the future,
$ pip install --upgrade --no-use-wheel pip setuptools
need to do it.
This is a compatibility issue between Homebrew and wheel.
Homebrew uses pip and setuptools when installing Python
/usr/local/Cellar/python/<version>/
Install it under it, and install symlink to the pip command etc. in ``` / usr / local / bin /
.
Then, write the setting prefix = / usr / local
in distutils.cfg
, and the package that is normally installed by pip install
etc. is a script under/ usr / local / bin /
, / usr Make sure the libraries are installed under /local/lib/pytthon2.7/
.
When I do pip install --upgrade pip
in this state, I want to install the / usr / local / bin / pip
script, but there is already a symlink that Homebrew does not detect. ..
The behavior when the symlink is already in the place where you want to install the script, but it is different between the installation from wheel and the installation from tar.gz, in the case of wheel it can not be installed and it is skipped, in the case of tar.gz Will rewrite the symlink's link (that is, the contents of Cellar).
Modern pips use the wheel by default, which leaves symlinks for scripts that try to use older versions of pip under Cellar, making them unbootable.
I don't think it's good that the behavior is different when using wheel and when not using it, but since there is no correct answer when installing by overwriting symlink created externally, Homebrew is pip install- If you allow -upgrade pip
, I think you should install pip normally from the beginning.
I have issued a Pull request that fixes pip and setuptools to stop installing inside Cellar. https://github.com/Homebrew/homebrew/pull/29926
The above PR was rejected because it did not match Homebrew's basic policy. So, just like when you don't use the wheel when installing with the wheel, you can publicize the fix to the pip side to overwrite (the link destination) even if the symbolic link already matches the script installation destination. It was captured.
Once the next pip (1.6.0) is released and bundled with Homebrew's Python, you should be able to upgrade normally with pip install --upgrade pip
from the next version.
That said, there are two pips inside and outside the Celler, and the script inside is rewritten when installing outside, which is far from smart. Unless you're in trouble, we recommend that you don't upgrade pip and wait for Homebrew to update.
Also, heavy Python developers may prefer to build their own using MacPorts or pyenv rather than Homebrew, which is forced by its own method.
pip install --upgrade pip
has been fixed, but pip install --user ipython
is still stuck and I don't know what other side effects there are around packaging.
Recommended Posts