You're missing the symbolic link that Homebrew makes from the Cellar to the actual bin directory on your path.
Use:
brew link python2
to fix that.
You may run into a warning:
Warning: python@2 is keg-only and must be linked with --force Note that doing so can interfere with building software.
See the accepted answer to this SO question for some details on that.
In most case, you can then safely use
brew link --force python2
if you're not planning building your own libraries that require the source code (libpython.so
and Python.h
) for Python 2.
If you do require the source code, you'll need to provide the include paths and library paths to e.g. /usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/include/python2.7
and /usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/
. But that's a different topic or question.
To use pip for Homebrew's Python 2, best to use is
python2 -m pip <command>
Then you can clearly see what Python your pip
command goes with, and keep it apart from Python 3 (which would be python3 -m pip
).
Note
If you have Homebrew problems, first cause of action is to run
brew doctor
The error messages are usually quite helpful to fix at some of the problems.