我有两个这样的包裹
com.abc.
protobuf.
share.proto
depart.
detect.proto
以及共享.proto像这样:
^{pr2}$以及检测.proto像这样:
syntax = "proto3";
package com.adc.depart;
import "com/abc/protobuf/share.proto"
编译共享.proto它的方向是这样的:
protoc -I=. --python_out=. share.proto
然后编译检测.proto它的方向是这样的:
protoc -I=/pathToSrcDir/ -I=. --python_out=. detect.proto
以及
pathToSrcDir has been added to PYTHONPATH
所有的编译都可以正常工作,但是当运行python脚本时
from com.abc.depart import detect_pb2
有这个错误吗
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "detect.proto":
detect.proto: Import "com/abc/protobuf/share.proto" has not been loaded.
com.abc.depert.XClass.ymethod: "com.abc.protobuf.Test" seems to be defined in "share.proto", which is not imported by "detect.proto". To use it here, please add the necessary import.
如何解决这个进口问题?在
有人回答了我的问题:https://github.com/google/protobuf/issues/4176,in简短地说,includes的不一致使用是根源,解决方案是
相关问题 更多 >
编程相关推荐