module 'collections' has no attribute 'Mapping', issue on MACOS for SDK installation

Viewed 9111

I tried to install Google Cloud SDK, on macOS, but it shows following error. Can anyone help please?

"Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/Users/kaab/google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
    import bootstrapping
  File "/Users/kaab/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 46, in <module>
    from googlecloudsdk.core.updater import update_manager
  File "/Users/kaab/google-cloud-sdk/lib/googlecloudsdk/core/updater/update_manager.py", line 39, in <module>
    from googlecloudsdk.core.console import progress_tracker
  File "/Users/kaab/google-cloud-sdk/lib/googlecloudsdk/core/console/progress_tracker.py", line 651, in <module>
    class _BaseStagedProgressTracker(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'"
1 Answers

Are you running Python 3.10? Switch to an older Python version. As of now, Cloud SDK officially suggests Python 3.5 to 3.8 and uses a feature that was finally deprecated in 3.10.

When I import from collections import Mapping in Python 3.9, I get the message:

<stdin>:1: DeprecationWarning: Using or importing the ABCs
  from 'collections' instead of from 'collections.abc' is deprecated
  since Python 3.3, and in 3.10 it will stop working

(ABC stands for abstract base class.)

This means that ever since Python 3.3 (almost ten years ago!) the correct way to import this is from collections.abc import Mapping, and the old way finally stopped working in Python 3.10.

I'd call it a bug in Google Cloud SDK, but their documentation actually suggests to use Python 3.5 to 3.8, so I suspect they have not tested it on 3.10. Maybe they'll fix it at some point.

Related