By default, MacOS come with a default version of Python, which is Python 2, but to install certain software such as Ansible and AWS Cli, you may need to have the Python 3+. But after you install the Python 3, it will not auto bind you the default Python, you may need to run Python3 everytime you want to use Python3, this is very irritating.
The following is the step to set the Python 3 to the default Python version.
Installing latest Python by using HomeBrew (https://brew.sh/)
brew install python
Check on the location and version being install
ls -l /usr/local/bin/python*
The following output showing the version of Python being install
lrwxr-xr-x 1 Apr 15 11:12 /usr/local/bin/python2.7 -> ../Cellar/python/3.7.7/bin/python2.7 lrwxr-xr-x 1 Apr 15 11:12 /usr/local/bin/python3 -> ../Cellar/python/3.7.7/bin/python3 lrwxr-xr-x 1 Apr 15 11:12 /usr/local/bin/python3-config -> ../Cellar/python/3.7.7/bin/python3-config lrwxr-xr-x 1 Apr 15 11:12 /usr/local/bin/python3.7 -> ../Cellar/python/3.7.7/bin/python3.7 lrwxr-xr-x 1 Apr 15 11:12 /usr/local/bin/python3.7-config -> ../Cellar/python/3.7.7/bin/python3.7-config lrwxr-xr-x 1 Apr 15 11:12 /usr/local/bin/python3.7m -> ../Cellar/python/3.7.7/bin/python3.7m lrwxr-xr-x 1 Apr 15 11:12 /usr/local/bin/python3.7m-config -> ../Cellar/python/3.7.7/bin/python3.7m-config
Change the default python symlink to the version that you want to use for.
Note that, we only need to choose the one that end with python3.*. Please avoid using the ones’ that end with config or python3.*m or python3.*m-config.
Below command shows how it should be done:
ln -s -f /usr/local/bin/python3.7 /usr/local/bin/python
Close the current terminal session or keep it that way and instead open a new terminal window (not tab). Run this:
You should get the Python version that you just link it