How to install python3.7 on a mac (mojave using homebrew

Solution 1:

The following procedure worked for me (in addition to the commands in the original question):

brew uninstall --ignore-dependencies python3
brew uninstall --force python#3.8
brew install python3

and adding the following line to .bash_profile:

alias python="python3"

For a Mac this was really easy! Only about 10 commands.

Solution 2:

Try using pyenv. This library will help you switch between different versions of Python (in case you need to run Python 2.x for some reason, and in anticipation of Python 4.0 coming).

Install pyenv

brew install pyenv

Now use pyenv to Install Python or Update Your Python Version

pyenv install 3.9.2

pyenv install 4.0.0

Check here link for more info.

Solution 3:

You should be able to access version 3.7 by entering:

python3.7

Depending on requirements and setup one can make adjustments to .bashrc (or bash_profile) with alias, something like:

alias python="python3.7"
alias python3="python3.6"

Of course, Python has version 3.8 out there and version 3.9 coming this fall.

EDIT:

Based on comment:

 brew info python
 /.../
 ==> 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/[email protected]/libexec/bin

/../

See: https://docs.brew.sh/Homebrew-and-Python

I see difference in path (libexec). This seems to be in line with comment of random guy off the internet

Solution 4:

You could use the Anaconda distribution of Python. Simple to install and simple to run in a virtual environment. Just run the installer at the link above. This is a very popular distribution of Python.