模块“six.moves”没有属性“collections_abc”

Jon*_*nis 3 python google-api six airflow

我有一个连接到 YouTube API 版本 3 并检索公共数据的脚本。这个脚本部署在气流中,它工作了一个月,今天它失败了,显示以下行的消息:

def youtube_search(term,region):
        youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY,cache_discovery=False)
Run Code Online (Sandbox Code Playgroud)
 File "/usr/local/airflow/.local/lib/python3.6/site-packages/googleapiclient/discovery.py", line 455, in build_from_document
    if isinstance(client_options, six.moves.collections_abc.Mapping):
AttributeError: module 'six.moves' has no attribute 'collections_abc'
Run Code Online (Sandbox Code Playgroud)

我去检查第455discovery.py

if isinstance(client_options, six.moves.collections_abc.Mapping):
        client_options = google.api_core.client_options.from_dict(client_options)
Run Code Online (Sandbox Code Playgroud)

six 模块并没有改变了很久,也没有我的脚本部署在流通,从而配置并没有任何改变。

由于Google模块 importsix并没有改变,我不明白为什么我会随机收到这个错误?

小智 8

您是明确指定了您正在使用的 google-api-python-client 版本,还是仅使用可用的最新版本?

20 年 9 月 14 日发布了新版本 (v1.12.0),随后是错误修复版本 v.1.12.1,修复了与six模块依赖项相关的错误。(来自 GitHub 的发布说明:需要 6>=1.13.0 (#1030) (4acecc3))

您可能会遇到 v1.12.0 中的错误。

  • 有趣的是,通过将大于 10 的数字放入结果数参数中,我能够得到同样的错误,因此还需要检查其他内容。我使用的是 google-api-python-client 版本 1.12.3,六个版本是 1.15.0,所以它也高于 1.13.0。 (3认同)