models icon indicating copy to clipboard operation
models copied to clipboard

ModuleNotFoundError: No module named 'pycocotools'

Open MyVanitar opened this issue 8 years ago • 13 comments

Hi,

When I try to run the eval.py to check the trained model on the validation dataset, I get the following error:

ModuleNotFoundError: No module named 'pycocotools

What's the reason of this?

MyVanitar avatar Feb 12 '18 08:02 MyVanitar

The reason is that it is not in your PYTHONPATH environment variable. You need to download and install this library

monomon avatar Feb 12 '18 08:02 monomon

@monomon

I have included all in the python path, otherwise the train.py should also show some errors, but it does not. By the way, what's its path. I should mention that I run on Windows and pycocotools seems to only be compatible with Linux.

MyVanitar avatar Feb 12 '18 08:02 MyVanitar

This is not true, I am using it on Windows. Could you show me your path, and where pycocotools is installed?

monomon avatar Feb 12 '18 09:02 monomon

Alright the problem solved.

I write for anyone who might face the same error in the Windows.

First, install Cython by pip install Cython

Second, install pycocotools by running pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI

MyVanitar avatar Feb 12 '18 09:02 MyVanitar

@monomon

if you run on windows, (the last repo), please check my another issue also because I have problems with CPU and GPU.

MyVanitar avatar Feb 12 '18 09:02 MyVanitar

Glad you solved it.

monomon avatar Feb 12 '18 09:02 monomon

@monomon I am having the same issue while I am running on Windows 10. It says ImportError: No module named 'pycocotools._mask' while I am trying to generate tf_record file for MSCOCO. Can you elaborate more on this how to solve that. pycocotools is installed in the environment.Thanks image

AVI18794 avatar Apr 04 '18 05:04 AVI18794

Also installed pycocotools in several different ways. I am able to run the train script and tensorboard fine, but no matter how I try to install pycocotools, the module is still "missing" when running the eval.py script.

miguelgamendes avatar Apr 04 '18 09:04 miguelgamendes

After using the makefile in the PythonAPI folder, exporting the whole folder to the PYTHONPATH variable seems to solve everything.

export PYTHONPATH:"[ABSOLUTE PATH TO PYTHONAPI FOLDER HERE]"

miguelgamendes avatar Jun 21 '18 10:06 miguelgamendes

Check this out and follow steps correctly .problem will be solved. https://github.com/philferriere/cocoapi

CHAMOD avatar Jun 26 '18 21:06 CHAMOD

If you get this error, it is because the COCO library you are calling is NOT our version of the library. Instead, you are (inadvertently) referencing a local copy of the library. So, if you get this error, search the tree of import in your code for a reference to a local pycocotools library. Then, move or delete the local version. ref here

haiyang-tju avatar Dec 10 '18 08:12 haiyang-tju

Thanks to @miguelgamendes I managed to install pycocotools and run eval.py in linux (using python 3.6) in 2 main steps :

  • Install the pycocotools from here

  • Export path :

export PYTHONPATH=$PYTHONPATH:<PATH_TO_PYTHONAPI_FOLDER>

or

export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

amtam0 avatar Jan 09 '19 16:01 amtam0

Please check https://github.com/tensorflow/models/issues/3829#issuecomment-494284442

osvadimos avatar May 21 '19 08:05 osvadimos