Invoking grpc.tools.protoc within python script vs as a python module in the command line

12 views
Skip to first unread message

Taran Deshpande

unread,
Aug 3, 2020, 4:13:56 PM8/3/20
to Protocol Buffers
 
I'm trying to invoke protoc within my python script. I am trying to use the grpc.tools.protoc.main() function within my script (the main function takes a list of the command line arguments as input).  However, the function call fails when the .proto file is referenced using an absolute or relative path, usually with the error:

You must specify a --proto_path which encompasses this file.  Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think)

However, when calling protoc from the command line as a module as "python3 -m grpc_tools.protoc" with the same arguments, it works in the expected way.  Any reason this could be happening? I am thinking it has to do with environment variables, but not quite sure.
Reply all
Reply to author
Forward
0 new messages