2

我创建了一个原型文件 RpcCmd.proto,并定义了一个类型为 的字段google.protobuf.Any,当我尝试使用 cmd 生成 Python3 目标文件时,protoc --python3_out=./gen RpcCmd.proto它失败并出现错误

Traceback (most recent call last):
  File "/usr/local/bin/protoc-gen-python3", line 36, in <module>
    compiler = Compiler(desc_map[file_name], top_level_elements)
  File "/usr/local/lib/python3.7/site-packages/protobuf3/compiler/__init__.py", line 54, in __init__
    self.process_message(message)
  File "/usr/local/lib/python3.7/site-packages/protobuf3/compiler/__init__.py", line 104, in process_message
    self.process_field(message.name, field, embedded)
  File "/usr/local/lib/python3.7/site-packages/protobuf3/compiler/__init__.py", line 148, in process_field
    file_to_import = splitext(self.__tle_map[top_level_name])[0].replace('/', '.')
KeyError: 'google'
--python3_out: protoc-gen-python3: Plugin failed with status code 1.

但是,如果我用 cmd 输入protoc --python_out=. RpcCmd.proto它就成功了

我也尝试--java_out过没有任何错误的工作。

syntax = "proto3";
import "google/protobuf/any.proto";

message RpcCmd {
    google.protobuf.Any message = 1;
    string randomKey = 2;
}

是否可以使用 type Anywith --python3_out

4

0 回答 0