How to Fix AttributeError: module ‘importlib’ has no attribute ‘util’

AttributeError - module 'importlib' has no attribute 'util'

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:

export CLOUDSDK_PYTHON=python2

To make this change permanent and ensure it’s applied every time you open a new terminal session:

  1. Open your ~/.bash_profile file in a text editor (e.g., nano ~/.bash_profile).
  2. Add the export CLOUDSDK_PYTHON=python2 command to the end of the file.
  3. Save and close the file.
  4. To apply the changes immediately, source your ~/.bash_profile by running source ~/.bash_profile.

It will fix the error!

Related posts

AttributeError: module ‘google.protobuf.descriptor’ has no attribute ‘_internal_create_key’

ImportError: cannot import name ‘builder’ from ‘google.protobuf.internal’

ModuleNotFoundError: no module named ‘google’

AttributeError: ‘module’ object has no attribute ‘misc’

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.