无法编译原型文件

时间:2018-10-09 07:05:59

标签: protocol-buffers

我在我的项目中创建了一个名为allinone.proto的原型文件。我想使用grpc创建一个服务,在其中我可以作为客户端调用。遵循此link中的教程之后, 我正在尝试在我的项目目录中运行命令以编译我刚刚创建的原型文件

$ python -m grpc_tools.protoc -I~/projects/All-In-One/models/grpc/ --python_out=. --grpc_python_out=. ~/projects/All-In-One/models/grpc/all_in_one.proto

原始文件的代码为

syntax = "proto3"

message ImageRGB {
    bytes content = 1;
}

message BoudingBox {
    int32 x = 1;
    int32 y = 2;
    int32 w = 3;
    int32 h = 4;
}

message Point2D {
    int32 x = 1;
    int32 y = 2;
}

message FaceDetections {
    repeated BoundingBox face_bbox = 1;
}

message FaceLandmarks {
    string landmark_model = 1;
    repeated Point2D point = 2;
}

message FaceLandmarkDescriptions {
    string landmark_model = 1;
    repeated string landmark_description = 2;
    repeated Point2D landmark_avg = 3;
}

message FaceLandmarkModels {
    repeated FaceLandmarkDescriptions model = 1;
}

}

我这样做有误

$python -m grpc_tools.protoc -I~/projects/All-In-One/models/grpc/ --python_out=. --grpc_python_out=. ~/projects/All-In-One/models/grpc/all_in_one.proto
~/projects/All-In-One/models/grpc/: warning: directory does not exist.
/home/samuel/projects/All-In-One/models/grpc/all_in_one.proto: File does not reside within any path specified using --proto_path (or -I).  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).

有人可以帮我弄清楚为什么会发生错误吗?

1 个答案:

答案 0 :(得分:0)

对不起,我不允许发表评论。

我猜想当您设置proto_path(-I)时,您可以使用基于它的相对路径。 你可以尝试这样的事情吗? python -m grpc_tools.protoc -I〜/ projects / All-In-One / models / grpc / --python_out =。 --grpc_python_out =。 all_in_one.proto