我正在尝试设置一个示例Python gRPC示例,并具有以下proto文件:
syntax = "proto3";
package greet;
service Greeter{
// unary
rpc SayHello (HelloRequest) returns (HelloReply);
// Server Streaming
rpc ParrotSayHello (HelloRequest) returns (stream HelloReply);
// Client Streaming
rpc ChattyClientSayHello (stream HelloRequest) returns (DelayedReply);
// Both Streaming
rpc InteractingHello (stream HelloReequest) returns (stream HelloReply);
}
项目结构为:
- 格雷特
- |- 原型
|- greet.protos
当我尝试使用以下命令运行协议时:
python -m grpc_tools.protoc -I./protos --python_out=. --grpc_python_out=. ./protos/greet.proto
我得到下面的错误:
greet.proto:8:17: "HelloRequest" is not defined.
greet.proto:8:40: "HelloReply" is not defined.
greet.proto:11:23: "HelloRequest" is not defined.
greet.proto:11:53: "HelloReply" is not defined.
greet.proto:14:36: "HelloRequest" is not defined.
greet.proto:14:59: "DelayedReply" is not defined.
greet.proto:17:32: "HelloReequest" is not defined.
greet.proto:17:63: "HelloReply" is not defined.
Pip列表确认我有可用的软件包:
(grpcenv)(base)问候语pip list软件包版本
图形输入输出1.51.1图形输入输出工具1.51.1 pip 22.3.1协议缓冲区4.21.12设置工具57.0.0滚轮0.36.2
1条答案
按热度按时间km0tfn4u1#
我正在查看代码,发现了这个问题,即原型不正确或不完整。
下面的proto解决了这个问题(错误正是问题所在!!!)