Skip to content Skip to sidebar Skip to footer

How To Downgrade Python Version From 3.8 To 3.7 (mac)

I'm using Python & okta-aws tools and in order to fetch correct credentials on aws I need to run okta-aws init. But got an error message of Could not read roles from Okta and t

Solution 1:

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

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 global3.7

Verify your current python version the system is using

python3 --version

Solution 2:

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

Solution 3:

brew only approach.

rm -rf $(brew --repository)/Library/Taps/company
brew tap-new company/team
brew extract python@3.7 company/team  --version=3.7.9 
HOMEBREW_NO_AUTO_UPDATE=1  brew install company/team/python@3.7.9
brew link --force company/team/python@3.7.9

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

Solution 4:

  • Reinstalled xcode-select (used solution here)
  • Downgraded python 3.9 to 3.8.12 (used @Shayan's solution here)
  • Restarted terminal and checked default Python version, that's all

This is my solution for M1 Mac

Post a Comment for "How To Downgrade Python Version From 3.8 To 3.7 (mac)"