-
Notifications
You must be signed in to change notification settings - Fork 16.1k
Python: with the generate_py_protobufs extension installed, cannot find google.api_core on import #7877
Copy link
Copy link
Closed
Description
What version of protobuf and what language are you using?
Version: master/v3.13.0.
Language: Python
OS: Linux
Python 3.7.0 and 3.8.5
tl;dr
If you import google.protobuf or proto prior to google.api_core, the module is found and loaded..
If you import google.api_core before importing these two if you attempt to import google.api_core the module is not found.
Why isn’t google.api_core found with the PathFinder in sys.meta_path find it?
I can duplicate this on my desktop, on a fresh cloudtop, and on our kokoro-ubuntu machines.
rwh@rhw8:python_cpp_pyext$ source /tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/bin/activate
(cpp_pyext) rwh@rhw8:python_cpp_pyext$ python
Python 3.8.5 (default, Sep 5 2020, 16:13:02)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import google.api_core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google.api_core'
>>> sys.meta_path
[<class '_frozen_importlib.BuiltinImporter'>, <class '_frozen_importlib.FrozenImporter'>, <class '_frozen_importlib_external.PathFinder'>]
>>> sys.path
['', '/usr/local/buildtools/current/sitecustomize', '/usr/local/google/home/rwh/.pyenv/versions/3.8.5/lib/python38.zip', '/usr/local/google/home/rwh/.pyenv/versions/3.8.5/lib/python3.8', '/usr/local/google/home/rwh/.pyenv/versions/3.8.5/lib/python3.8/lib-dynload', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/protobuf_distutils-1.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/google_ads-6.0.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/setuptools-44.0.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/proto_plus-1.9.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/grpcio-1.32.0rc1-py3.8-linux-x86_64.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/googleapis_common_protos-1.52.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/google_api_core-1.22.2-py3.8.egg']
>>> import google.protobuf
>>> sys.meta_path
[<class '_frozen_importlib.BuiltinImporter'>, <class '_frozen_importlib.FrozenImporter'>, <class '_frozen_importlib_external.PathFinder'>, <pkg_resources.extern.VendorImporter object at 0x7ff1f5bfea00>, <pkg_resources._vendor.six._SixMetaPathImporter object at 0x7ff1f5b8d880>]
>>> sys.path
['', '/usr/local/buildtools/current/sitecustomize', '/usr/local/google/home/rwh/.pyenv/versions/3.8.5/lib/python38.zip', '/usr/local/google/home/rwh/.pyenv/versions/3.8.5/lib/python3.8', '/usr/local/google/home/rwh/.pyenv/versions/3.8.5/lib/python3.8/lib-dynload', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/protobuf_distutils-1.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/google_ads-6.0.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/setuptools-44.0.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/proto_plus-1.9.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/grpcio-1.32.0rc1-py3.8-linux-x86_64.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/googleapis_common_protos-1.52.0-py3.8.egg', '/tmp/cpp-pyext-O2Xfh0IBIS/cpp_pyext/lib/python3.8/site-packages/google_api_core-1.22.2-py3.8.egg']
>>> import google.api_core
>>>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels