Was getting the following error on macOS when installing Google Cloud SDK:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Error: Failure while executing; `/usr/bin/env PATH=/usr/local/bin:/usr/local/sbin:/usr/local/Homebrew/Library/Homebrew/shims/scm:/usr/bin:/bin:/usr/sbin:/sbin /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/install.sh --usage-reporting false --bash-completion false --path-update false --rc-path false --quiet` exited with 1. Here's the output: Welcome to the Google Cloud SDK! Traceback (most recent call last): File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module> import bootstrapping File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module> import setup # pylint:disable=g-import-not-at-top File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/bootstrapping/setup.py", line 57, in <module> from googlecloudsdk.core.util import platforms File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module> from googlecloudsdk.core.util import importing File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module> import imp File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module> from importlib import util File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module> from . import abc File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module> from typing import Protocol, runtime_checkable File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module> import re as stdlib_re # Avoid confusion with the re we export. File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module> import enum File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module> spec = importlib.util.find_spec('enum') AttributeError: module 'importlib' has no attribute 'util' |
I suspected it’s because I had Python 3.9 installed and that was being used (notice it says python@3.9 in the errors) but Google Cloud SDK only supports up to Python 3.8.
How to get brew
to use Python 3.8 just for this install though? Wasn’t sure. I tried being sneaky and make aliases pointing python3
and python3-config
to point to the python@3.8
installed versions but that didn’t help. I couldn’t uninstalled the python@3.9
package either as it was required by others.
I downloaded the tar ball from the Google Cloud website and tried a manual install with the same results. Then I noticed the install.sh
script mentions a CLOUDSDK_PYTHON
variable to specify the Python version. So I tried CLOUDSDK=python3.8 ./install.sh
and voila! that worked.
After successfully installing I had further trouble running the gcloud
command as it gave the same error. So I added export CLOUDSDK_PYTHON=python3.8
to my .bash_profile
so the cloud SDK always uses Python 3.8. That helped.