from google.cloud import ndb fails unless grpc is imported first
pb-jeff-oneill opened this issue · 1 comments
pb-jeff-oneill commented
Environment details
google-cloud-ndb==1.11.1 # Also tried 1.12.0 with same result
protobuf==3.20.3 # See https://stackoverflow.com/questions/72441758
python 3.7.13 # Also tried 3.8.13
macOS Big Sur 11.7.2
Normally, I can import grpc fine:
$ python
Python 3.7.13 (default, Aug 1 2022, 17:01:49)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.auth.transport.grpc
>>>
But importing ndb fails with a grpc import error:
$ python
Python 3.7.13 (default, Aug 1 2022, 17:01:49)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import ndb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.../.pyenv/versions/.../lib/python3.7/site-packages/google/cloud/ndb/__init__.py", line 28, in <module>
from google.cloud.ndb.client import Client
File "/.../.pyenv/versions/.../lib/python3.7/site-packages/google/cloud/ndb/client.py", line 26, in <module>
from google.cloud.datastore_v1.gapic import datastore_client
File "/.../.pyenv/versions/3.7.13/envs/.../lib/python3.7/site-packages/google/cloud/datastore_v1/__init__.py", line 18, in <module>
from google.cloud.datastore_v1.gapic import datastore_client
File "/.../.pyenv/versions/3.7.13/envs/.../lib/python3.7/site-packages/google/cloud/datastore_v1/gapic/datastore_client.py", line 24, in <module>
import google.api_core.gapic_v1.client_info
File "/.../.pyenv/versions/3.7.13/envs/.../lib/python3.7/site-packages/google/api_core/gapic_v1/__init__.py", line 18, in <module>
from google.api_core.gapic_v1 import method
File "/.../.pyenv/versions/3.7.13/envs/.../lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 24, in <module>
from google.api_core import grpc_helpers
File "/.../.pyenv/versions/3.7.13/envs/.../lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 26, in <module>
import google.auth.transport.grpc
ModuleNotFoundError: No module named 'google.auth.transport.grpc'
Though this works:
$ python
Python 3.7.13 (default, Aug 1 2022, 17:01:49)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.auth.transport.grpc
>>> from google.cloud import ndb
>>>
Strangely, I seem to be the only one having this issue...
pb-jeff-oneill commented
The problem was caused by having:
/.../google-cloud-sdk/platform/google_appengine
in my PYTHONPATH. That was added years ago when I was working on first gen GAE apps and only recently did it cause a problem.