Hi All
I am trying to implement the Google Cloud Tasks V2 Python libs.
Have tried to follow the docs. https://cloud.google.com/tasks/docs/creating-appengine-tasks
There are no mention of how to install the protobuf requirement required for:
from google.protobuf import timestamp_pb2.
Without this the follow error is produced:
cannot import name 'resource_pb2' from 'google.api' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api/__init__.py)
Have tried to pip install protobuf.
How to fix + please update docs.
Trying to reproduce:
$ python3.6 -m venv /tmp/gcp/7812
$ /tmp/gcp/7812/bin/pip install --upgrade setuptools pip wheel
...
Successfully installed pip-19.1 setuptools-41.0.1 wheel-0.33.1
$ /tmp/gcp/7812/bin/pip install google-cloud-tasks
...
Successfully installed cachetools-3.1.0 certifi-2019.3.9 chardet-3.0.4 google-api-core-1.9.0 google-auth-1.6.3 google-cloud-tasks-0.7.0 googleapis-common-protos-1.5.9 grpc-google-iam-v1-0.11.4 grpcio-1.20.1 idna-2.8 protobuf-3.7.1 pyasn1-0.4.5 pyasn1-modules-0.2.5 pytz-2019.1 requests-2.21.0 rsa-4.0 six-1.12.0 urllib3-1.24.2
$ /tmp/gcp/7812/bin/python
Python 3.6.7 (default, Oct 22 2018, 11:30:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import tasks
>>> from google.api import resource_pb2
Please use the installation directions for the google-cloud-tasks library.
Docs are wrong they state:
from google.protobuf import timestamp_pb2
The resolution seems to be:
from google.api import resource_pb2
How do we report a bug in the docs?
For anyone getting stuck on this issue, make sure all your google-* packages are up to date, especially googleapis-common-protos==1.5.10. Updating this fixed the import issue for me.
I was having the same issue with the pubsub module and this fixed it indeed:
pip install -U googleapis-common-protos==1.5.10
Most helpful comment
For anyone getting stuck on this issue, make sure all your
google-*packages are up to date, especiallygoogleapis-common-protos==1.5.10. Updating this fixed the import issue for me.