I've been trying to install pip on macOS sierra via brew, but every time it completes without installing the binaries in /usr/local/Cellar/python/2.7.13/bin
.
I've tried:
MacBook-Pro ➜ brew reinstall python
then:
MacBook-Pro ➜ ~ which pip
pip not found
I found the path to python, which is /usr/local/Cellar/python/2.7.13/bin
but no binary for pip there.
I also tried the easy_install
approach:
MacBook-Pro ➜ sudo easy_install pip
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 11, in <module>
load_entry_point('setuptools==18.5', 'console_scripts', 'easy_install')()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 352, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2307, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2021, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
UPDATE:
When I run brew postinstall python
I am getting the following error:
MacBook-Pro ➜ ~ brew postinstall python
==> Using the sandbox
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --rec
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --rec
Last 15 lines from /Users/justin/Library/Logs/Homebrew/python/post_install.02.python:
Traceback (most recent call last):
File "setup.py", line 92, in <module>
cmdclass={'test': PyTest},
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.py", line 225, in __init__
_Distribution.__init__(self,attrs)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.py", line 258, in finalize_options
ep.load()(self, ep.name, value)
File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2020, in load
raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError: <module 'setuptools.dist' from '/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.pyc'> has no 'check_specifier' attribute
OK gang, lots of these answers where helpful but none of them got me to the finish line. I am running High Sierra 10.13.4. The problem as documented above is that Brew installs pip in the
/usr/local/bin
directory but Python is in/usr/bin
(although as Carl said, Python3 correctly goes to/usr/local/bin
).My immediate use case is related to getting the Postgres BigSQL package to install.
The steps I took are as follows:
$ rm -rf ~/Library/Caches/Homebrew
$ sudo rm -rf /usr/local/lib/python2.7/site-packages
$ brew reinstall python
This pulls downpython-3.5.6.high_sierra
and put it in/usr/local/bin/python3
which python
still shows/usr/bin/python
brew install python@2
which pulls downpython@2-2.7.14_3.high_sierra
which python
shows the correct path/usr/local/bin/python
which is also where all your pip stuff is installed, so now pip will work.sudo pip install --upgrade pip
The error message has the answer for you...
Remove
/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/
and runbrew reinstall python
.setuptools
is the wrong version.You just need to install
pip
which is not automatically installed in macOS Sierra.Run
sudo easy_install pip
I had this issue and I found this to be the solution. BTW pip isn't installed via brew. It comes with python and python virtualenvs.
if you type
which python
withoutbrew install python
you'll get the location in/usr/bin/python
. That is the system python which we don't want to develop with.So i took the following steps. 1)
brew install python
2)export PATH="/usr/local/opt/python/libexec/bin:$PATH"
place that in your~/.bash_profile
3)source ~/.bash_profile
in your terminal 4) typewhich python
and that should have changed the location to/usr/local/opt/python/libexec/bin/python
.This will allow you to pip install normally and use the brew version of python.
Now before high sierra python used to be located in
/usr/local/bin
but for some reason if you place/usr/local/bin
in your paths it automatically points back to/usr/bin
, so this is the only solution I have been able to come up with.Python3 does not have this issue, if you
brew install python3
and typewhich python3
you'll see that it's located in/usr/local/bin/python3
.For Mac OS Sierra, cannot install pip via
easy_install
since there is a problem with TLS Version, Installed Open-SSL version won't support TLS 1.2So install pip using curl as follows,
Something must be wrong with your brew installation.
Latest macOS version.