ModuleNotFoundError: No module named 'pycocotools'
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?
The reason is that it is not in your PYTHONPATH environment variable.
You need to download and install this library
@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.
This is not true, I am using it on Windows. Could you show me your path, and where pycocotools is installed?
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
@monomon
if you run on windows, (the last repo), please check my another issue also because I have problems with CPU and GPU.
Glad you solved it.
@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

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.
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]"
Check this out and follow steps correctly .problem will be solved. https://github.com/philferriere/cocoapi
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
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
Please check https://github.com/tensorflow/models/issues/3829#issuecomment-494284442