I have python 3.7 installed but will need to run something with python 3.6. Here are the steps to do so.
[code] brew unlink python brew install –ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb brew switch python 3.6.5 [/code]
To switch it back to python 3.7
[code] brew switch python 3.7.0 [/code]
Now with two versions installed, we can use virtualenv for projects.
Notice that when you issue virtualenv –python=$(which python3) env, virtualenv may throw an error -bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python3.7: bad interpreter: No such file or directory. That’s because the virtualenv script has a shebang line referencing python 3.7. To fix that error, edit that file /usr/local/bin/virtualenv and change the version to 3.6. Then virtualenv will work fine.
Ref: https://stackoverflow.com/questions/51726203/installing-python3-6-alongside-python3-7-on-mac https://stackoverflow.com/questions/45269867/python-virtualenvwrapper-bad-interpreter/48259762#48259762