Search code examples
pythonprotocol-buffersgrpcfile-descriptor

protofile.proto: A file with this name is already in the pool


Having the following structure:

- project1
  - project1.py
  - protofile_pb2.py
  - protofile_pb2_grpc.py
- project2
  - project2.py
  - protofile_pb2.py
  - protofile_pb2_grpc.py

project1.py:

import protofile_pb2.py
...

project2.py:

import protofile_pb2
import project1
...

When running project2.py, I get this error:

TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "protofile.proto":
protofile.proto: A file with this name is already in the pool.

Solution

  • You are using different versions of your generated protofile.proto. Make sure to regenerate the protobuf files and it should work fine.