How to solve modulenotfounderror: no module named pycocotools

How to solve modulenotfounderror: no module named pycocotools

This tutorial will cover the solutions for the "modulenotfounderror: no module named pycocotools" Error. And at the end of this article, you will be able to solve the error.

Solution 1: Install the pycocotools packages

The most reason for "modulenotfounderror: no module named pycocotools" is the package is not installed. However, our first solution is Installing the pycocotools packages. 

To install the packages choose your preferred method (PIP is Recommended).


# Pip Python 2
pip install pycocotools
# Pip Python 3
pip3 install pycocotools


conda install -c conda-forge pycocotools

If the problem is not solved, Don't worry because We have more solutions for you.

Solution 2: ensure using Python >= 3

I figured out that in Python 2, the modulenotfounderror error appears even though the pycocotools packages are installed. Therefore make sure you have Python 3. 

Run the following command to check if you have Python 3:

python3 -V

My output:

Python 3.9.5

Check out Install Python on Windows, Mac, and Linux If Python3 is not installed,

Solution 3: Install the cython packages

If the previous solutions are not working, Try to install the cython packages. Here are the commands:


pip3 install Cython


conda install -c anaconda cython

Solution 4: Install Visual C++ Build Tools for windows

You must install Visual C++ Build Tools for Windows to solve the error. You can visit How To Install Build Tools And C++ Compiler For Windows.


Alright, we're done with the solutions of "modulenotfounderror: no module named pycocotools". I hope your error has been fixed.

For more information about modulenotfounderror, I recommend you to visit this ModuleNotFoundError: No module named in Python.

Happy Coding ♥