How to downgrade python version from 3.8 to 3.7 (mac)
Consider installing pyenv
with Homebrew on macOS
brew update
brew install pyenv
OR Clone the repository to get the latest version of pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
Define your environment variables
(For a recent MacOS you may want to replace ~/.bash_profile
with ~/.zshrc
as that is the default shell)
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
Restart your shell so the path changes take effect
exec "$SHELL"
Verify the installation and check the available python
versions
pyenv install --list
Install the required python
version
pyenv install 3.7
Set it as your global version after installation
pyenv global 3.7
Verify your current python
version the system is using
python3 --version
brew only approach.
rm -rf $(brew --repository)/Library/Taps/company
brew tap-new company/team
brew extract [email protected] company/team --version=3.7.9
HOMEBREW_NO_AUTO_UPDATE=1 brew install company/team/[email protected]
brew link --force company/team/[email protected]
This creates a local tap, extracts python 3.7.X to a formula in that local tap and then installs and links that formula
The created local tap and the new formula file can be found in
$(brew --repository)/Library/Taps/company/homebrew-team
I recommend you to install and use pyenv, a Python Version Management. Once intalled pyenv, install python 3.7:
pyenv install 3.7
And then set the environment PYENV_VERSION
to version of python you want to use, on this case will be 3.7:
pyenv shell 3.7