Search code examples
pythongoogle-apiairflowsix

module 'six.moves' has no attribute 'collections_abc'


I have a script that connects to YouTube API version 3 and retrieves public data. This script is deployed in airflow, it was working fine for a month, today it failed with this message for the following line:

def youtube_search(term,region):
        youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY,cache_discovery=False)
 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'

I went to check the 455th line on discovery.py

if isinstance(client_options, six.moves.collections_abc.Mapping):
        client_options = google.api_core.client_options.from_dict(client_options)

The six module has not changed for a long time, nor has my script deployed in airflow, which config has not changed either.

As Google module imports six, which has not changed, I can't figure out why would I get this error at random?


Solution

  • Are you explicitly specifying the version of google-api-python-client that you're using, or just using the latest version available?

    There was a new version (v1.12.0) released on 9/14/20, followed by a bug fix version v.1.12.1 that fixes a bug related to the dependency on the six module. (release notes from GitHub: require six>=1.13.0 (#1030) (4acecc3))

    You may be running into the bug in v1.12.0.