New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name label_map_util #1990

Open
tcexeexe opened this Issue Jul 20, 2017 · 15 comments

Comments

Projects
None yet
@tcexeexe

tcexeexe commented Jul 20, 2017

l follow the Installation step to install in python2.7,debian 8 and pass the "model_builder_test.py"
but when l run the Object Detection Demo,the error happend:

root@australia_debian1:~/PycharmProjects/objdetection# ipython example.py

ImportError Traceback (most recent call last)
/root/PycharmProjects/objdetection/example.py in ()
17 # This is needed since the notebook is stored in the object_detection folder.
18 sys.path.append("..")
---> 19 from utils import label_map_util
20
21 from utils import visualization_utils as vis_util

ImportError: cannot import name label_map_util

dose anyone know how to solve this problem?

@asimshankar

This comment has been minimized.

Show comment
Hide comment
@asimshankar

asimshankar Jul 21, 2017

Member

I apologize but I am having a hard time understanding what the problem is, where the problem is, and what version it affects. Please resubmit and pay attention to the issue template (https://github.com/tensorflow/tensorflow/issues/new) . Please provide all the information it asks. Thank you.

In particular, detailed instructions to reproduce the problem will be most helpful.
As of now, it is not clear to me whether the notebook file is in the expected directory from where it can access all the libraries. (From your log it seems you're using some file called example.py, where is that coming from? There is no such file in the object_detection directory)

Member

asimshankar commented Jul 21, 2017

I apologize but I am having a hard time understanding what the problem is, where the problem is, and what version it affects. Please resubmit and pay attention to the issue template (https://github.com/tensorflow/tensorflow/issues/new) . Please provide all the information it asks. Thank you.

In particular, detailed instructions to reproduce the problem will be most helpful.
As of now, it is not clear to me whether the notebook file is in the expected directory from where it can access all the libraries. (From your log it seems you're using some file called example.py, where is that coming from? There is no such file in the object_detection directory)

@sjwhhhi

This comment has been minimized.

Show comment
Hide comment
@sjwhhhi

sjwhhhi Aug 1, 2017

I have the same question
You can change label_map_util.py (in utils folder) line 22 to
from protos import string_int_label_map_pb2.

sjwhhhi commented Aug 1, 2017

I have the same question
You can change label_map_util.py (in utils folder) line 22 to
from protos import string_int_label_map_pb2.

@RobinBaumann

This comment has been minimized.

Show comment
Hide comment
@RobinBaumann

RobinBaumann Aug 3, 2017

I have faced the same error: I found out that I only get it when running my commands from another directory than the project root directory.

To see if you installed the API correctly, you can run the following command from the tensorflow/models directory:

python object_detection/protos/label_map_util_test.py

It should print out OK.

Edit: There are indentation errors in the test file from line 79-107

RobinBaumann commented Aug 3, 2017

I have faced the same error: I found out that I only get it when running my commands from another directory than the project root directory.

To see if you installed the API correctly, you can run the following command from the tensorflow/models directory:

python object_detection/protos/label_map_util_test.py

It should print out OK.

Edit: There are indentation errors in the test file from line 79-107

@ayushmaan

This comment has been minimized.

Show comment
Hide comment
@ayushmaan

ayushmaan Nov 8, 2017

Hi, I solve this just

  1. git clone https://github.com/tensorflow/models in tensorflow folder.

From tensorflow/models/research/

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

3)# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

ayushmaan commented Nov 8, 2017

Hi, I solve this just

  1. git clone https://github.com/tensorflow/models in tensorflow folder.

From tensorflow/models/research/

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

3)# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

@Viveco

This comment has been minimized.

Show comment
Hide comment
@Viveco

Viveco Dec 4, 2017

I have faced the same error: ImportError: cannot import name 'label_map_util'
so The file in ‘object_detection/utils’

Viveco commented Dec 4, 2017

I have faced the same error: ImportError: cannot import name 'label_map_util'
so The file in ‘object_detection/utils’

@mordka

This comment has been minimized.

Show comment
Hide comment
@mordka

mordka Dec 13, 2017

After cloning tensorflow models, running protoc object_detection/protos/*.proto --python_out=. and exporting PYTHONPATH it still failed but changing the import helped:
from object_detection.utils import label_map_util

mordka commented Dec 13, 2017

After cloning tensorflow models, running protoc object_detection/protos/*.proto --python_out=. and exporting PYTHONPATH it still failed but changing the import helped:
from object_detection.utils import label_map_util

@karthi-keyan

This comment has been minimized.

Show comment
Hide comment
@karthi-keyan

karthi-keyan Dec 26, 2017

I have faced the same error: ImportError: cannot import name 'label_map_util'
i just install setup.py in research folder and i copied that object_detection and .egg.info in sitepackages folder

karthi-keyan commented Dec 26, 2017

I have faced the same error: ImportError: cannot import name 'label_map_util'
i just install setup.py in research folder and i copied that object_detection and .egg.info in sitepackages folder

@imvinaypatil

This comment has been minimized.

Show comment
Hide comment
@imvinaypatil

imvinaypatil Jan 18, 2018

I tried running these commands as mentioned from a jupyter notebook:

git clone https://github.com/tensorflow/models in tensorflow folder.

From tensorflow/models/research/

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

3)# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

but it still doesnot work

imvinaypatil commented Jan 18, 2018

I tried running these commands as mentioned from a jupyter notebook:

git clone https://github.com/tensorflow/models in tensorflow folder.

From tensorflow/models/research/

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

3)# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

but it still doesnot work

@monomon

This comment has been minimized.

Show comment
Hide comment
@monomon

monomon Jan 18, 2018

This seems to be coming up very frequently - make sure object_detection is in your PYTHONPATH!

monomon commented Jan 18, 2018

This seems to be coming up very frequently - make sure object_detection is in your PYTHONPATH!

@duancaohui

This comment has been minimized.

Show comment
Hide comment
@duancaohui

duancaohui Mar 21, 2018

My system is windows 10, python 3.6 and I install protoc-3.4.0-win32 not protoc-3.5.0-win32, protoc-3.5 for windows has bug!!!
After running protoc object_detection/protos/*.proto --python_out=.
just change
from utils import label_map_util
to
from object_detection.utils import label_map_util

duancaohui commented Mar 21, 2018

My system is windows 10, python 3.6 and I install protoc-3.4.0-win32 not protoc-3.5.0-win32, protoc-3.5 for windows has bug!!!
After running protoc object_detection/protos/*.proto --python_out=.
just change
from utils import label_map_util
to
from object_detection.utils import label_map_util

@alaparthishivaji

This comment has been minimized.

Show comment
Hide comment
@alaparthishivaji

alaparthishivaji Mar 22, 2018

I am facing issue in windows 10 ,python 3.6 in object detection can any one help me out these, i am facing errors as name 'label_map_util' is not defined & No module named 'utils'

alaparthishivaji commented Mar 22, 2018

I am facing issue in windows 10 ,python 3.6 in object detection can any one help me out these, i am facing errors as name 'label_map_util' is not defined & No module named 'utils'

@AdityaPai2398

This comment has been minimized.

Show comment
Hide comment
@AdityaPai2398

AdityaPai2398 Jun 26, 2018

I am facing the same problem right now from utils import label_map_util

ModuleNotFoundError: No module named 'utils'

It mostly happens if you've changed the working directory,so you need to add it to the PATH

AdityaPai2398 commented Jun 26, 2018

I am facing the same problem right now from utils import label_map_util

ModuleNotFoundError: No module named 'utils'

It mostly happens if you've changed the working directory,so you need to add it to the PATH

@Viveco

This comment has been minimized.

Show comment
Hide comment
@Viveco

Viveco Jun 26, 2018

I am faceing issue in Mac ,python 3.5.6. I add the path ,but it still doesn't work , I try to do it. like :
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

so,not working . I ask question for my teacher, so he tell me the Mac operating system is ‘Unix’,unlike linux。 Every time I do this, it doesn't work。

Viveco commented Jun 26, 2018

I am faceing issue in Mac ,python 3.5.6. I add the path ,but it still doesn't work , I try to do it. like :
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

so,not working . I ask question for my teacher, so he tell me the Mac operating system is ‘Unix’,unlike linux。 Every time I do this, it doesn't work。

@AdityaPai2398

This comment has been minimized.

Show comment
Hide comment
@AdityaPai2398

AdityaPai2398 Jul 2, 2018

@Viveco what's the protoc version that you're using?

AdityaPai2398 commented Jul 2, 2018

@Viveco what's the protoc version that you're using?

@parmarmanoj007

This comment has been minimized.

Show comment
Hide comment
@parmarmanoj007

parmarmanoj007 Aug 17, 2018

import like this...

from object_detection.utils import label_map_util

parmarmanoj007 commented Aug 17, 2018

import like this...

from object_detection.utils import label_map_util

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment