我想使用proto文件,它已经在
googleapis/api-common-protos
在巨蟒中。例如
syntax = "proto3";
package com.example.service.rev0;
import "google/protobuf/any.proto";
import "google/rpc/code.proto";
message GenericExcInfo {
google.rpc.Code status_code = 1;
string name = 2;
string message = 3;
repeated string stack_trace_entries = 4;
string code_filename = 5;
int32 code_lineno = 6;
string code_name = 7;
google.protobuf.Any arbitrary_info = 16;
}
如果python包
googleapis-common-protos
安装了相关的python模块(在本例中,
google.rpc.code_pb2.Code
)有空。但是由于没有安装proto文件,我得到了以下错误。
$ protoc --proto_path=. --python_out=. exc_info.proto
google/rpc/code.proto: File not found.
exc_info.proto: Import "google/rpc/code.proto" was not found or had errors.
exc_info.proto:14:5: "google.rpc.Code" is not defined.
如何在python中使用这些google proto文件?我一定要
git clone
在编译时包含所有proto文件?