Installing Tensorflow and object detection errors -**ImportError: cannot import name 'builder' from 'google.protobuf.internal'

Full disclosure, python etc is not my strong point i’m learning and following tutorials, however the ease at which all of these fail is frustrating. I am following the tutorials and then something breaks or doesnt work and then spend hours trying to fix it only for something else to break !

I am following the tutorial here: Installation — TensorFlow 2 Object Detection API tutorial documentation

Ill list my commands step by step in the hope some one can tell me what im doing wrong

conda create -n tensorflow pip python=3.9

conda activate tensorflow

pip install --ignore-installed --upgrade tensorflow==2.5.0

python -c “import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))”

protoc object_detection/protos/*.proto --python_out=.

(no output is shown or errors)

pip install cython

pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

cp object_detection/packages/tf2/setup.py .

python -m pip install .

python object_detection/builders/model_builder_tf2_test.py

Traceback (most recent call last):

File “C:\tensorflow\models\research\object_detection\builders\model_builder_tf2_test.py”, line 24, in

from object_detection.builders import model_builder

File “C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\object_detection\builders\model_builder.py”, line 23, in

from object_detection.builders import anchor_generator_builder

File “C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\object_detection\builders\anchor_generator_builder.py”, line 26, in

from object_detection.protos import anchor_generator_pb2

File “C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\object_detection\protos\anchor_generator_pb2.py”, line 5, in

from google.protobuf.internal import builder as _builder

ImportError: cannot import name ‘builder’ from ‘google.protobuf.internal’ (C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\google\protobuf\internal_init_.py)

1 Like

Hi @Alistair_Phillips, I have run the above commands in wsl environment with Tensorflow 2.15 and did not face any error.

Thank You.

Could it be working because you’re using Linux? Because it doesn’t work properly on windows @Kiran_Sai_Ramineni