模块“collections”没有属性“Mapping”,MACOS 上的 SDK 安装问题

问题描述 投票:0回答:1

我尝试在 macOS 上安装 Google Cloud SDK,但显示以下错误。 有人可以帮忙吗?

"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'"
python macos terminal sdk cloud
1个回答
37
投票

您运行的是 Python 3.10 或更高版本吗?切换到较旧的 Python 版本。截至目前,Cloud SDK 官方建议使用 Python 3.5 至 3.8,并使用最终在 3.10 中弃用的功能。

当我在 Python 3.9 中导入

from collections import Mapping
时,我收到消息:

<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代表抽象基类。)

这意味着从 Python 3.3 开始(差不多十年前!),导入它的正确方法是

from collections.abc import Mapping
,而旧方法最终在 Python 3.10 中停止工作。

我认为这是 Google Cloud SDK 中的一个错误,但他们的文档实际上建议使用 Python 3.5 到 3.8,所以我怀疑他们还没有在 3.10 上进行测试。也许他们会在某个时候修复它。

© www.soinside.com 2019 - 2024. All rights reserved.