Probably the safest and easy way is to use brew and then just modify your PATH
:
First update brew:
brew update
Next install python:
brew install python
That will install and symlink python3 to python, for more details do:
brew info python
Look for the Caveats:
==> Caveats
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
Then add to your path /usr/local/opt/python/libexec/bin
:
export PATH=/usr/local/opt/python/libexec/bin:$PATH
The order of the PATH
is important, by putting first the /usr/local/opt/python/libexec/bin
will help to give preference to the brew install (python3) than the one is in your system located in /usr/bin/python