Skip to content

Can't generate python client #1785

Closed
Closed
@mkuklik

Description

@mkuklik

🐛 Bug Report

Python client generation fails using grpio_tools.I am using a_bit_of_everything.proto from examples.

To Reproduce

  1. in the root directory of grpc-gateway I run
python` -m grpc_tools.protoc a_bit_of_everything.proto --python_out=./proto/ --grpc_python_out=./proto/ \
  	--proto_path `pwd`/examples/internal/proto/examplepb
  1. in python

import a_bit_of_everything_pb2

Expected behavior

Actual Behavior

When trying to import a_bit_of_everything_pb.py I get the following errors,

Traceback (most recent call last):
File "", line 1, in
File "/Users/mkuklik/tshub/grpc-gateway/a_bit_of_everything_pb2.py", line 20, in
from protoc_gen_openapiv2.options import annotations_pb2 as protoc__gen__openapiv2_dot_options_dot_annotations__pb2
File "/Users/mkuklik/tshub/grpc-gateway/protoc_gen_openapiv2/options/annotations_pb2.py", line 18, in
DESCRIPTOR = _descriptor.FileDescriptor(
File "/Users/mkuklik/tshub/grpc-gateway/examples/internal/proto/examplepb/.venv/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 941, in new
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "annotations.proto":
protoc-gen-openapiv2/options/openapiv2.proto: Import "protoc-gen-openapiv2/options/openapiv2.proto" has not been loaded.
grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger: "grpc.gateway.protoc_gen_openapiv2.options.Swagger" seems to be defined in "openapiv2.proto", which is not imported by "annotations.proto". To use it here, please add the necessary import.
grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation: "grpc.gateway.protoc_gen_openapiv2.options.Operation" seems to be defined in "openapiv2.proto", which is not imported by "annotations.proto". To use it here, please add the necessary import.
grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema: "grpc.gateway.protoc_gen_openapiv2.options.Schema" seems to be defined in "openapiv2.proto", which is not imported by "annotations.proto". To use it here, please add the necessary import.
grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag: "grpc.gateway.protoc_gen_openapiv2.options.Tag" seems to be defined in "openapiv2.proto", which is not imported by "annotations.proto". To use it here, please add the necessary import.
grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field: "grpc.gateway.protoc_gen_openapiv2.options.JSONSchema" seems to be defined in "openapiv2.proto", which is not imported by "annotations.proto". To use it here, please add the necessary import.

Even if I generate code for protoc-gen-openapiv2/options/ and protoc-gen-openapiv2/options/openapiv2.proto
and place them in ./grpc/gateway/protoc_gen_openapiv2/options/

I still get:

Invalid proto descriptor for file "annotations.proto":
protoc-gen-openapiv2/options/openapiv2.proto: Import "protoc-gen-openapiv2/options/openapiv2.proto" has not been loaded.
grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger: "grpc.gateway.protoc_gen_openapiv2.options.Swagger" seems to be defined in "openapiv2.proto", which is not imported by "annotations.proto". To use it here, please add the necessary import.

Your Environment

System:
Darwin mbp-geum 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

Python:
appier==1.20.5
cachetools==4.1.1
certifi==2020.6.20
chardet==3.0.4
google-api==0.1.12
google-api-core==1.23.0
google-auth==1.23.0
googleapis-common-protos==1.52.0
grpcio==1.33.2
grpcio-tools==1.33.2
idna==2.10
protobuf==3.13.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pytz==2020.1
requests==2.24.0
rsa==4.6
six==1.15.0
urllib3==1.25.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions