ImportError: cannot import name 'builder' from 'google.protobuf.internal'

When i tested the file

python object_detection/builders/

, i encountered the following error.

Traceback (most recent call last):
  File "C:\Users\yunpeng\models\research\object_detection\builders\", line 24, in <module>
    from import model_builder
  File "C:\Users\yunpeng\anaconda3\envs\tf2\lib\site-packages\object_detection\builders\", line 23, in <module>
    from import anchor_generator_builder
  File "C:\Users\yunpeng\anaconda3\envs\tf2\lib\site-packages\object_detection\builders\", line 26, in <module>
    from object_detection.protos import anchor_generator_pb2
  File "C:\Users\yunpeng\anaconda3\envs\tf2\lib\site-packages\object_detection\protos\", line 5, in <module>
    from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (C:\Users\yunpeng\anaconda3\envs\tf2\lib\site-packages\google\protobuf\internal\

How should you resolve this error?


Could you please upgrade the protobuf package as shown below and let us know?

pip install --upgrade protobuf

Thank you!

thanks,i have solved it

there is same error in tensorflow exam, but they told us to install protobuf==3.19.6 only, if I update the protobuf, another error arises


Welcome to the Tensorflow Forum,

I would appreciate if you could open a new issue with standalone code and a stack trace so that it is easy to track and assist you quickly.

Thank you!

I have the same error. But when I upgrade the protobuf, I have this message>

Requirement already satisfied: protobuf in c:\users\alvaro felipe\desktop\tensorflow object detection\tfodcourse\tfod\lib\site-packages (3.19.4)
Collecting protobuf
Obtaining dependency information for protobuf from
Using cached protobuf-4.24.4-cp37-cp37m-win_amd64.whl.metadata (540 bytes)
Using cached protobuf-4.24.4-cp37-cp37m-win_amd64.whl (430 kB)
Installing collected packages: protobuf
Attempting uninstall: protobuf
Found existing installation: protobuf 3.19.4
Uninstalling protobuf-3.19.4:
Successfully uninstalled protobuf-3.19.4
Successfully installed protobuf-4.24.4
ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
apache-beam 2.48.0 requires protobuf<4.24.0,>=3.20.3, but you have protobuf 4.24.4 which is incompatible.
tensorboard 2.11.2 requires protobuf<4,>=3.9.2, but you have protobuf 4.24.4 which is incompatible.
tensorflow-intel 2.11.0 requires protobuf<3.20,>=3.9.2, but you have protobuf 4.24.4 which is incompatible.