Homebrew upgrades packages to the latest versions whenever it tries to install a package. This has caused problems multiple times for me especially with the Python version.
Recently Homebrew upgraded Python version on my Mac from 3.8
from 3.9
. This has
caused problems with gcloud
. I installed python 3.8
version using
brew install python@3.8
. The installation was successful but python3
still referring to the newer version i.e python 3.9
.
The trick is to update the PATH
to use Python 3.8. I’ve performed the
following steps to revert Python version to Python 3.8.
brew info python@3.8
After you run this command you will see lot of information, find the following lines
If you need to have python@3.8 first in your PATH run:
echo 'export PATH="/usr/local/opt/python@3.8/bin:$PATH"' >> ~/.zshrc
-
Execute the command as-is
echo 'export PATH="/usr/local/opt/python@3.8/bin:$PATH"' >> ~/.zshrc
-
Refresh your shell,
zsh -l
In my case it is zsh. You can also close and open your terminal. -
Run
python3 --version
. You should seePython 3.8.X
.