首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法编译proto文件

无法编译proto文件
EN

Stack Overflow用户
提问于 2018-10-09 15:05:59
回答 1查看 1.5K关注 0票数 1

我已经在我的项目中创建了一个名为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文件的代码是

代码语言:javascript
运行
复制
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;
}

}

执行此操作时出现错误

代码语言:javascript
运行
复制
$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).

有人能帮我弄清楚为什么会发生这个错误吗?

EN

回答 1

Stack Overflow用户

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52715142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档