Reputation: 9396
I had on OSX High Sierra versions 2.7 and 3.6 and correspondingly pip
and pip3
installed. The terminal commands python
and pip
were linked to Python2 while python3
and pip3
to python3`
I upgraded my Python3 version with homebrew
. The installation was successful but now I have to link the command for python3. homebrew
suggests:
Linking /usr/local/Cellar/python/3.7.6_1...
Error: Could not symlink Frameworks/Python.framework/Headers
Target /usr/local/Frameworks/Python.framework/Headers is a symlink belonging to python@2. You can unlink it:
brew unlink python@2
To force the link and overwrite all conflicting files:
brew link --overwrite python
To list all files that would be deleted:
brew link --overwrite --dry-run python
However this would link python3 to python
terminal command while I want a separate python3
and pip3
commands.
How to do that?
Upvotes: 1
Views: 3446
Reputation: 19849
However this would link python3 to
python
terminal command
That’s not true. Homebrew links python
to either its own Python 2 or the system Python. It never links it to Python 3:
Homebrew provides one formula for Python 3.x (python) and another for Python 2.7.x (python@2).
The executables are organised as follows so that Python 2 and Python 3 can both be installed without conflict:
- python3 points to Homebrew’s Python 3.x (if installed)
- python2 points to Homebrew’s Python 2.7.x (if installed)
- python points to Homebrew’s Python 2.7.x (if installed) otherwise the macOS system Python. Check out brew info python if you wish to add Homebrew’s 3.x python to your PATH.
- pip3 points to Homebrew’s Python 3.x’s pip (if installed)
- pip and pip2 point to Homebrew’s Python 2.7.x’s pip (if installed)
Emphasis mine. Source: https://docs.brew.sh/Homebrew-and-Python#python-3x-or-python-2x
You should thus be fine linking python@3
. If you can’t do so, you can add $(brew --prefix python)/bin
to your PATH
to get all python3
and similar binaries.
Upvotes: 1