0

I've written a service with gRPC. When I start the service, it can't import compiled protobuf and shows the following error message:

from google.protobuf import descriptor as _descriptortitus| ModuleNotFoundError: No module named 'google'
Pouya Esmaeili
  • 1,265
  • 4
  • 11
  • 25

1 Answers1

1

tried to reproduct your problem.

And there is all fine in my configuration.

Looks like there is multiple google packages in pip.
And one named google actually not official google's package.
Did you used pip install google to install google package?

I did it as below

pip install protobuf
pip freeze
protobuf==3.13.0
six==1.15.0
from google.protobuf import descriptor
dir(descriptor)
['Descriptor', 'DescriptorBase', 'DescriptorMetaclass', 'EnumDescriptor', 'EnumValueDescriptor', 'Error', 'FieldDescriptor', 'FileDescriptor', 'MakeDescriptor', 'MethodDescriptor', 'OneofDescriptor', 'ServiceDescriptor', 'TypeTransformationError', '_Deprecated', '_Lock', '_NestedDescriptorBase', '_OptionsOrNone', '_ParseOptions', '_ToCamelCase', '_ToJsonName', '_USE_C_DESCRIPTORS', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_internal_create_key', '_lock', '_message', 'api_implementation', 'binascii', 'os', 'six', 'threading', 'warnings']

My python version is

Python 3.6.7 (default, Dec  5 2018, 15:02:05) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
rzlvmp
  • 7,512
  • 5
  • 16
  • 45