The protoc generate xxx_pb2_grpc.py code like this for example:
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
import shadowfax_pb2 as shadowfax__pb2
However, in some case, line 3 will fail with an Error:
ModuleNotFoundError: No module named 'shadowfax_pb2'
How about changing this line to:
from . import shadowfax_pb2 as shadowfax__pb2
Here is my workaround in macOS
cd py_protos && sed -i '' 's/^\(import.*pb2\)/from . \1/g' *.py
@nathanielmanistaatgoogle, can you help to take a look?
I suspect that this is the same problem that we're tracking in gRPC Python issue 11041 and gRPC Python issue 9450.
I am closing this issue as duplicated with some issues under gRPC
See https://github.com/protocolbuffers/protobuf/issues/1491 for a discussion of this issue.
Most helpful comment
Here is my workaround in macOS