我已经在我的项目中创建了一个名为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
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).
有人能帮我弄清楚为什么会发生这个错误吗?
发布于 2018-10-11 01:59:35
对不起,我不允许用评论来回复。
我猜当您设置proto_path(-I)时,您可以使用基于它的相对路径。你能试一下这样的东西吗?python -m grpc_tools.protoc -I~/projects/All-In-One/models/grpc/ --python_out=.--grpc_python_out=。all_in_one.proto
https://stackoverflow.com/questions/52715142
复制相似问题