Installing Python3.6 alongside Python3.7 on Mac

Solution 1:

Try using brew for example if already using Python 3:

$ brew unlink python

Then install python 3.6.5:

$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

To get back to python 3.7.4_1 use:

$ brew switch python 3.7.4_1

And if need 3.6 again switch with:

$ brew switch python 3.6.5_1

Solution 2:

If you are using mac, you can install pyenv from Brew, install the desired versions, list the installed versions, and activate each version locally or globally.

brew install pyenv
pyenv install 3.6.9
pyenv install 3.7.4    
pyenv versions
pyenv global 3.7.4 3.6.9
$ python3.6 --version 
Python 3.6.9 

$ python3.7 --version
Python 3.7.4

PS: Global activation worked only after restarting the computer. You need to prepend $(pyenv root)/shims to the left of your PATH environment variable.