Models: ImportError: No module named 'pycocotools'

Created on 1 Apr 2018  ·  7Comments  ·  Source: tensorflow/models

Most helpful comment

Hi @robieta, I think the confusion arises because in the Installation.md, it says

Download the cocoapi and copy the pycocotools subfolder to the tensorflow/models/research directory _if you are interested in using COCO evaluation metrics_

which gave me the impression that if I don't need to use the COCO evaluation metrics then I don't need to install it, resulting in this import error when I run the evaluation script. Possible to modify the wording there to make it sound compulsory?

All 7 comments

Same problem too.

Traceback (most recent call last):
File "object_detection/eval.py", line 50, in
from object_detection import evaluator
File "/home/eco/tensorflow/models/research/object_detection/evaluator.py", line 24, in
from object_detection import eval_util
File "/home/eco/tensorflow/models/research/object_detection/eval_util.py", line 28, in
from object_detection.metrics import coco_evaluation
File "/home/eco/tensorflow/models/research/object_detection/metrics/coco_evaluation.py", line 20, in
from object_detection.metrics import coco_tools
File "/home/eco/tensorflow/models/research/object_detection/metrics/coco_tools.py", line 47, in
from pycocotools import coco
ImportError: No module named pycocotools

Installation of cocoapi is covered in https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

I'm going to close this issue. If you followed these instructions and are still having issues feel free to reopen and @ me.

Hi @robieta, I think the confusion arises because in the Installation.md, it says

Download the cocoapi and copy the pycocotools subfolder to the tensorflow/models/research directory _if you are interested in using COCO evaluation metrics_

which gave me the impression that if I don't need to use the COCO evaluation metrics then I don't need to install it, resulting in this import error when I run the evaluation script. Possible to modify the wording there to make it sound compulsory?

That seems reasonable.

It is still there, and still confusing. I got the same error for my custom dataset

The way I've solved it (and the way I solve all similar ones) :
git clone [email protected]:cocodataset/cocoapi.git
make # might be not necessary
python setup.py build
python setup.py install

All above when you've activated you virtual environment. Or will be installed globally at your wish.

pycocotools_mask.c(4): fatal error C1083: 无法打开包括文件: “Python.h”: No such file or directory

Was this page helpful?
0 / 5 - 0 ratings