Skip to content

ImportError: cannot import six.moves.collections_abc #45

@wescpy

Description

@wescpy
Traceback (most recent call last):
    . . .
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/main.py", line 16, in <module>
    from google.cloud import ndb
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/ndb/__init__.py", line 28, in <module>
    from google.cloud.ndb.client import Client
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/ndb/client.py", line 26, in <module>
    from google.cloud.datastore_v1.gapic import datastore_client
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/datastore_v1/__init__.py", line 18, in <module>
    from google.cloud.datastore_v1.gapic import datastore_client
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/datastore_v1/gapic/datastore_client.py", line 39, in <module>
    from google.cloud.datastore.version import __version__
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/datastore/__init__.py", line 60, in <module>
    from google.cloud.datastore.client import Client
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/datastore/client.py", line 26, in <module>
    from google.cloud.datastore._http import HTTPDatastoreAPI
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/datastore/_http.py", line 19, in <module>
    from google.cloud import _http as connection_module
  File "/base/data/home/apps/m~PROJECT_ID/20201117t171012.431016593202024462/lib/google/cloud/_http.py", line 22, in <module>
    from six.moves import collections_abc
ImportError: cannot import name collections_abc
  • This affects all Python 2 App Engine users as six==1.12.0 is built-in
  • The current workaround is to reference the immediately preceding version by adding google-cloud-core==1.4.1 in any affected application's requirements.txt file until either App Engine revs six to a newer release (>=1.13.0), or Line 22 of google/cloud/_http.py is patched, perhaps with something like this:
# catch six<1.13.0
try:
    from six.moves import collections_abc
except ImportError:
    # catch python<3.3.0
    try:
        import collections.abc as collections_abc # only works on 3.3+
    except ImportError:
        import collections as collections_abc

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions