3

I'm trying to deploy a gRPC server to Cloud Run using Docker to create associated image. I am getting the following error when called:

[] Traceback (most recent call last):
      > []   File "server.py", line 5, in <module>
      > []     from servicers import PredictionServiceServicer
      > []   File "/src/servicers.py", line 5, in <module>
      > []     import google.cloud.logging
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging/__init__.py", line 18, in <module>
      > []     from google.cloud.logging_v2 import __version__
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/__init__.py", line 25, in <module>
      > []     from google.cloud.logging_v2.client import Client
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/client.py", line 22, in <module>
      > []     from google.cloud.logging_v2 import _gapic
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/_gapic.py", line 18, in <module>
      > []     from google.cloud.logging_v2.services.config_service_v2 import ConfigServiceV2Client
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/services/config_service_v2/__init__.py", line 16, in <module>
      > []     from .client import ConfigServiceV2Client
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/services/config_service_v2/client.py", line 35, in <module>
      > []     from google.cloud.logging_v2.services.config_service_v2 import pagers
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/services/config_service_v2/pagers.py", line 27, in <module>
      > []     from google.cloud.logging_v2.types import logging_config
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/types/__init__.py", line 16, in <module>
      > []     from .log_entry import (
      > []   File "/usr/local/lib/python3.6/site-packages/google/cloud/logging_v2/types/log_entry.py", line 26, in <module>
      > []     __protobuf__ = proto.module(
      > [] AttributeError: module 'proto' has no attribute 'module'
 - deployment/****-service failed. Error: container *******-service-container terminated with exit code 1.
Cleaning up...

My Dockerfile is:

FROM python:3.6.8-slim
RUN apt-get update
RUN apt-get install python3 python3-pip -y

ENV PYTHONUNBUFFERED 1
    
RUN pip3 install --no-cache-dir --upgrade pip

ENV PORT 8080

COPY . ./

ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION "cpp"
    
RUN pip3 install -r requirements.txt
    
WORKDIR "/src"

EXPOSE 50051

CMD ["python3", "server.py"]

with requirements.txt being:

argparse
proto-plus 
grpcio 
grpcio-tools
google-cloud-logging #==1.15.1
google-cloud-datastore #==1.15.3
google-cloud-bigquery #==1.14.0

Though I have been playing around with different variations of base image and pip/pip3 imstalls of protobuf etc so any suggestions are welcome. Also when i run:

pip3 uninstall protobuf

I get three options. Deleted 3.19.1 but still getting error:

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/protobuf/*
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/protobuf-3.19.1-py3.8-nspkg.pth
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/protobuf-3.19.1.dist-info/*
Alex
  • 778
  • 1
  • 15
user3385136
  • 513
  • 1
  • 7
  • 20
  • Additional info: when i downgrade google-cloud package < v2.0.0 it works but obviously that's not a solution as v2 google-cloud packages are required. – user3385136 Jan 27 '22 at 16:34

1 Answers1

0

I found these similar issues that were caused by using different versions of protobuf and protoc. The first and the second cases suggest running this command:

  pip3 install --upgrade protobuf

Another case in Github issues suggest downloading certain modules as you already did and get rid of the issue; but as you said, this was not a solution for the usage of certain modules of the latest version.

And, there is the last case where the protobuf module was causing issues with “MutableMapping” and was solved by changing the imports. I’m not really sure if this could also be the case here, but I am adding it because it might be useful. It would be of great help if you could provide feedback on trying to follow this troubleshooting.

Alex
  • 778
  • 1
  • 15
  • Thanks for the suggestions @Alex. Will try them out and let you know. – user3385136 Jan 28 '22 at 16:22
  • Sure, please provide feedback on the results! – Alex Jan 31 '22 at 17:32
  • 1
    Sorry. None of the above helped. I ended up starting from scratch on gcp cloud editor for a clean environment and everything worked. I assume I have a package version issue on my local machine but will try to diagnose when I have the time. Sorry, no resolution. – user3385136 Feb 09 '22 at 09:14