Docker中带Protobuf的Python“TypeError:无法将proto文件构建到描述符池中!”

时间:2017-12-13 04:03:08

标签: python docker protocol-buffers

我有一个使用协议缓冲区的python应用程序。我试图让它在Docker中运行,但是当我执行docker run时它会抛出错误:

以下是Dockerfile内容:

 FROM python:3.5-onbuild
 CMD [ "python", "./main.py" ]

这是错误:

bash-3.2$ docker run gcr.io/skroot-com/geo-boundary-refiner:0.1
Traceback (most recent call last):
  File "./main.py", line 14, in <module>
    from skroot.schema.pipeline.event import geo_boundary_marked_pb2
  File "/usr/src/app/skroot/schema/pipeline/event/geo_boundary_marked_pb2.py", line 18, in <module>
    from skroot.schema.pipeline import image_info_pb2 as skroot_dot_schema_dot_pipeline_dot_image__info__pb2
  File "/usr/src/app/skroot/schema/pipeline/image_info_pb2.py", line 26, in <module>
    dependencies=[skroot_dot_schema_dot_pipeline_dot_cloud__storage__location__pb2.DESCRIPTOR,skroot_dot_schema_dot_pipeline_dot___matrix__pb2.DESCRIPTOR,])
  File "/usr/local/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 829, in __new__
    return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "image_info.proto":
  image_info.proto: Import "skroot/schema/pipeline/cloud_storage_location.proto" has not been loaded.
  image_info.proto: Import "skroot/schema/pipeline/matrix.proto" has not been loaded.
  skroot.schema.pipeline.ImageInfo.Image.location: "skroot.schema.pipeline.CloudStorageLocation" seems to be defined in "cloud_storage_location.proto", which is not imported by "image_info.proto".  To use it here, please add the necessary import.
  skroot.schema.pipeline.ImageInfo.TranscodedImage.matrix: "skroot.schema.pipeline.Matrix" seems to be defined in "matrix.proto", which is not imported by "image_info.proto".  To use it here, please add the necessary import.

image_info.proto文件中,导入了抱怨的.proto文件:

import "skroot/schema/pipeline/cloud_storage_location.proto";
import "skroot/schema/pipeline/matrix.proto";

生成的protobuf文件位于skroot/schema/pipeline/目录中。

我很困惑,因为它在本地运行。只有当我尝试在Docker中运行它时才会出现这些错误。

0 个答案:

没有答案