# ImportError: cannot import name 'string_int_label_map_pb2' #1595

Closed
opened this Issue Jun 17, 2017 · 23 comments

Projects
None yet

# ImportError Traceback (most recent call last) in () ----> 1 from utils import label_map_util 2 3 from utils import visualization_utils as vis_util D:\Personal\learn\ML\DL\Tensorflow\Official-Tutorial\models-master\object_detection\utils\label_map_util.py in () 20 import tensorflow as tf 21 from google.protobuf import text_format ---> 22 from object_detection.protos import string_int_label_map_pb2 23 24 ImportError: cannot import name 'string_int_label_map_pb2'

To workaround/proceed I commented the following line in "label_map_util.py"
from object_detection.protos import string_int_label_map_pb2

NameError: name 'string_int_label_map_pb2' is not defined

So need your help to solve the error in step "Object detection imports"
Appreciate the help to proceed further

### matmoody commented Jun 17, 2017

 Make sure you run protoc object_detection/protos/*.proto --python_out=. as mentioned in installation instructions: https://github.com/tensorflow/models/blob/master/object_detection/g3doc/installation.md

### bsrinivas84 commented Jun 17, 2017

 Thanks mat for the quick response. I am unable to locate the tensorflow/models directory. Couple of hits got me to these links, but It did not help me find the directory tensorflow/tensorflow#5953 tensorflow/tensorflow#5953 For windows OS, the steps need to be better? Please help
Member

### derekjchow commented Jun 17, 2017

 @bsrinivas84 tensorflow/models refers to the root of the git checkout.

### bsrinivas84 commented Jun 18, 2017

 Thanks Derek, realized first I had to install protoc-3.2.0-windows-x86_64.exe from https://github.com/google/protobuf/releases (pointed environment variables to include the path to installation) and then go to root and run the command. It worked, Many Thanks

Closed

Closed

### maheshmadhusudanan commented Jun 25, 2017

 Anybody who is getting an import error in Jupyter notebook even after updating the PYTHONPATH make sure you restart the notebook. (i wasted couple of hours trying to chase down this problem)

Merged

### devilsnare007 commented Dec 3, 2017

 @fera0013 , if you're on windows and running that command it won't work, for some reason it doesn't recognize /* as iterating thru all .proto files, you will have to manually (or create a batch file) do all .proto files one by one: D:\Tensorflow_Object_Detection_API\protoc-3.5\bin\protoc object_detection/protos/"filename.proto" --python_out=. ##Running this from the folder containing protoc.exe ##

### tawaki commented Dec 20, 2017 • edited

 I am using windows 10 with python 3.6.3 instead of using protoc object_detection/protos/*.proto --python_out=. I use for %i in (object_detection\protos\*.proto) DO protoc %i --python_out=. set PYTHONPATH=\$PYTHONPATH:pwd:pwd/slim it create .py file for each .proto file in that folder. However, I also have the same problem when run from object_detection.protos import string_int_label_map_pb2 still have error ImportError: cannot import name 'string_int_label_map_pb2 If I run from protos import string_int_label_map_pb2 another error shows up ModuleNotFoundError: No module named 'protos' Is there other way to solve this problem?

### gedeon1310 commented Jan 10, 2018

 On windows 10, assuming that you fixed protoc issues as indicated above, I also ran commands: python setup.py build then python setup.py install for in research folder and slim folder (you may also have encountered some import issues with commands like ''from nets import ... ) I then copied copied related egg files into my libray path (related to my tensorflow environment): C:\Users\test\Anaconda3\envs\tensorflow\Lib\site-packages I finally have in this folder following files: slim-0.1-py3.5.egg object_detection-0.1-py3.5.egg and folders: slim.egg-info object_detection.egg-info this allowed to run from Anaconda prompt (in_..\models\research_) the test command indicated in installation guidelines: python object_detection/builders/model_builder_test.py

### yash486gadhavi commented Feb 26, 2018

 In my case, the proto folder contains no file named 'string_int_label_map_pb2' instead there is a file named string_int_label_map.proto but still i am not able to import that file please help me

### jcRisch commented Mar 8, 2018

 My problems was : protos correctly build pb2 files "from object_detection import anchor_generator_pb2" returns no error using the python2.7 console but returned an error with "python2.7 object_detection/builders/model_builder_test.py" command On Ubuntu17 and with tensorflow 1.6 @gedeon1310 's solution worked for me too. Thanks

### Flyzzz commented Sep 1, 2018

 same problom on windows7, download protoc-3.6.1-win32.zip，place protoc.exe to environment path ,then copy protoc.exe to C:\Windows\systerm32，then run complie protoc object_detection/protos/*.proto --python_out=.，done