AttributeError: module ‘importlib’ has no attribute ‘util’ error occurs when you “upgraded from Fedora 32 to Fedora 33 (which comes with Python 3.9) and gcloud stopped working!”
How to fix it?
To fix the AttributeError: module ‘importlib’ has no attribute ‘util’ error, “update gcloud sdk to the latest version.”
To update to the latest version, use this command:
gcloud components update
If you are using Fedora 33, which includes Python 2.7, and wish to force the gcloud SDK to use Python 2.7 instead of the default Python version, you can set the CLOUDSDK_PYTHON environment variable:
To make this change permanent and ensure it’s applied every time you open a new terminal session:
- Open your ~/.bash_profile file in a text editor (e.g., nano ~/.bash_profile).
- Add the export CLOUDSDK_PYTHON=python2 command to the end of the file.
- Save and close the file.
- To apply the changes immediately, source your ~/.bash_profile by running source ~/.bash_profile.
It will fix the error!