I'm having trouble linking python3 and making python3 the default python.
MacOS 10.13.6
Here's what I did:
$ python --version
Python 2.7.15
$ python3 --version
Python 3.7.0
$ xcode-select --version
xcode-select version 2349.
$ brew install python
...
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
...
It doesn't work. python
is still 2.*
$ python --version
Python 2.7.15
$ python3 --version
Python 3.7.0
$ pip --version
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
$ pip3 --version
pip 18.0 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
So I did:
$ brew link python3
Warning: Already linked: /usr/local/Cellar/python/3.7.0
To relink: brew unlink python && brew link python
$ python --version
Python 2.7.15
$ brew install python3
...
Warning: python 3.7.0 is already installed and up-to-date
To reinstall 3.7.0, run `brew reinstall python`
$ brew reinstall python
Also doesn't work
$ brew link python3
Warning: Already linked: /usr/local/Cellar/python/3.7.0
To relink: brew unlink python && brew link python
$ python --version
Python 2.7.15
$ python3 --version
Python 3.7.0
For brewed Python, modules installed with pip or python3 setup.py install will be installed to the $(brew --prefix)/lib/pythonX. Y/site-packages directory (explained above).
I presume you mean that you want the command python
to start the Python3 interpreter, and pip
to start pip3
.
The clue is in the message:
Unversioned symlinks
python
,python-config
,pip
etc. pointing topython3
,python3-config
,pip3
etc., respectively, have been installed into /usr/local/opt/python/libexec/bin
That means... "if you want the command python
to start python3
and pip
to start pip3
, you need to put /usr/local/opt/python/libexec/bin
at the start of your PATH."
So, in your login script ($HOME/.profile
or similar), you need to put:
export PATH=/usr/local/opt/python/libexec/bin:$PATH
Then log out and log back in for it to take effect.
As an aside, brew link python3
only means... "create a symbolic link in /usr/local/bin/python3
that points to /usr/local/Cellar/python/3.7.0/python3
".
You can see that link, and where it points to, with:
ls -l /usr/local/bin/python3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With