Thanks a lot
I am having the following error
"ImportError: No module named 'pycocotools'"
Can you please advice me how to install it as I could not find it on pip or conda?
I tried the installation from https://github.com/cocodataset/cocoapi but did not work too
Solved using
https://github.com/cocodataset/cocoapi
Cloning https://github.com/waleedka/coco (which is @waleedka's fork of the coco API), then running
python PythonAPI/setup.py build_ext install
installed pycocotools to site-packages and resolved the import error.
The package pycocotools requires cython and a C compiler to install correctly. You can also install pycocotools as follows:
pip install git+https://github.com/waleedka/cocoapi.git#egg=pycocotools&subdirectory=PythonAPIpip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPIgit clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
sudo make install
sudo python setup.py install
before doing above steps install cython
Updated the README file to include installation instructions for pycocotools. Thanks @philferriere
thanks!
On sudo make install I've got error:
python setup.py build_ext install
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from Cython.Build import cythonize
ImportError: No module named Cython.Build
Makefile:7: recipe for target 'install' failed
make: *** [install] Error
I am using python 3.6 and I have both cython and h5py, any ideas why this is happening??
$ conda list cython & conda list h5py
[1] 18446
# packages in environment at /home/yerong/local/Anaconda3:
#
# Name Version Build Channel
h5py 2.7.1 py36h3585f63_0
# packages in environment at /home/yerong/local/Anaconda3:
#
# Name Version Build Channel
cython 0.27.3 py36h1860423_0
I fixed the issue above by linking python in the Makefile with my conda python:
# Makefile
all:
# install pycocotools locally
/home/yerong/local/Anaconda3/bin/python setup.py build_ext --inplace
rm -rf build
install:
# install pycocotools to the Python site-packages
/home/yerong/local/Anaconda3/bin/python setup.py build_ext install
rm -rf build
I fixed this way:
pip install -U scikit-image
pip install -U cython
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI
@utahman Same, but with the command
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
Hello All,
I am using miniconda and i want to install the pycocotools to me conda environment, not my global environment
When i try to run conda_env/bin/pip install git+https://github.com/waleedka/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI
It prompts me for username and I don't think it is asking for my username.
Does anyone know how to get around this issue?
I am avoiding make install because I am not familiar with make and I don't want to accidentally install things outside of my conda environment.
However, I am opened to suggestions if anyone can tell me how to install to conda environment using make.
--- Update ---
I tried the suggestion from @YerongLi and modified my make file to:
all:
# install pycocotools locally
/home/jkuo/miniconda3/envs/test/bin/python setup.py build_ext --inplace
rm -rf build
install:
# install pycocotools to the Python site-packages
/home/jkuo/miniconda3/envs/test/bin/python setup.py build_ext install
rm -rf build
and then i run the following commands:
make install
python setup.py install
Then I see pycocotools in my site-package:

However, I still get the ModuleNotFoundError: No module named 'pycocotools'

---Fixed---
Follow the solution of this post
run 'conda install notebook' in the env and jupyter notebook again
Thanks,
JC
The solution suggested by @G-mel works like a charm in UbuntuGnome 16.04, Python 3.6 and it directly installs it to site-packages. Thus, no import errors are faced.
The easiest way I found and it has worked for me on Mac, Ubuntu and Windows:
pip3 install git+https://github.com/waleedka/coco.git#subdirectory=PythonAPI
The full installation steps that I use with conda on Python 3.6 (tested this on Ubuntu 18.04 only):
conda install cudatoolkit cudnn tensorflow-gpu keras cython opencv
pip install imgaug
pip install git+https://github.com/waleedka/coco.git#subdirectory=PythonAPI
Thanks @philferriere. The pip install hosted on github repo worked well!
@pirahagvp I use cocotools, and I meet the following problems.
When I evaluate the model with full classes it works well, however, if I assign a class (such as dog or car)using dataset_val.load_coco(), I get an error:
Traceback (most recent call last):
File "coco.py", line 531, in
coco = dataset_val.load_coco(args.dataset, "val", class_ids=class_names, year=args.year, return_coco=True, auto_download=args.download)
File "coco.py", line 135, in load_coco
self.add_class("coco", i, coco.loadCats(i)[0]["name"])
File "/home/f214/anaconda2/envs/maskrcnn/lib/python3.4/site-packages/pycocotools-2.0-py3.4-linux-x86_64.egg/pycocotools/coco.py", line 218, in loadCats
return [self.cats[id] for id in ids]
File "/home/f214/anaconda2/envs/maskrcnn/lib/python3.4/site-packages/pycocotools-2.0-py3.4-linux-x86_64.egg/pycocotools/coco.py", line 218, in
return [self.cats[id] for id in ids]
KeyError: 'd'
Exception ignored in:
Traceback (most recent call last):
File "/home/f214/anaconda2/envs/maskrcnn/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 712, in __del__
TypeError: 'NoneType' object is not callable
Hello...I am trying to install this and getting following error.. I have MS Visual Studio Build Tools 2017 installed.
Could you please help to resolve this issue?
F:\Amit\download\coco-master\coco-master\PythonAPI>python setup.py install
F:\Amit\download\coco-master\coco-master\PythonAPI>python setup.py install
Compiling pycocotools/_mask.pyx because it changed.
[1/1] Cythonizing pycocotools/_mask.pyx
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6pycocotools
copying pycocotools__init__.py -> build\lib.win-amd64-3.6pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.6pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.6pycocotools
running build_ext
building 'pycocotools._mask' extension
Error: Error executing cmd /u /c "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 && set
F:\Amit\download\coco-master\coco-master\PythonAPI>
As @waleedka implicitly mentioned in his comment from Jun 5, the URL of the git repo recently changed.
The easiest way I found and it has worked for me on Mac, Ubuntu and Windows:
pip3 install git+https://github.com/waleedka/coco.git#subdirectory=PythonAPI
I found it useful to add the #egg string when installing the package from github:
pip3 install git+https://github.com/waleedka/coco.git#egg=pycocotools&subdirectory=PythonAPI
I have followed following steps:
@utahman Same, but with the command
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
This is the second time I am trying to install cocotools. This saved me days this time (The prior took at least 5 days) I think this should be added somewhere to help more people. Thanks a lot!
now easy way
$pip search pycocotools
pycocotools (2.0.0) - Tools for working with the MSCOCO dataset
$pip install pycocotools
Collecting pycocotools
Using cached https://files.pythonhosted.org/packages/96/84/9a07b1095fd8555ba3f3d519517c8743c2554a245f9476e5e39869f948d2/pycocotools-2.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "
File "/tmp/pip-install-j5hm4oy3/pycocotools/setup.py", line 2, in
from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-j5hm4oy3/pycocotools/
**
pip install Cython
pip install pycocotools
it is ok,well done!
I didn't figure it out using all the above methods, but the following one:
which cython
编辑上一步输出的文件,将里面第一行的最后一个单词从python改为python3
Anybody ran into the same problem. Tried all the suggestions above.
Collecting pycocotools
Using cached https://files.pythonhosted.org/packages/96/84/9a07b1095fd8555ba3f3d519517c8743c2554a245f9476e5e39869f948d2/pycocotools-2.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "
File "/tmp/pip-build-895bapp3/pycocotools/setup.py", line 29, in
cythonize(ext_modules)
File "/home/yves/.local/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 958, in cythonize
ctx = c_options.create_context()
File "/home/yves/.local/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 595, in create_context
self.cplus, self.language_level, options=self)
File "/home/yves/.local/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 78, in __init__
from . import Builtin, CythonScope
File "/home/yves/.local/lib/python3.6/site-packages/Cython/Compiler/CythonScope.py", line 5, in
from .UtilityCode import CythonUtilityCode
File "/home/yves/.local/lib/python3.6/site-packages/Cython/Compiler/UtilityCode.py", line 3, in
from .TreeFragment import parse_from_strings, StringParseContext
File "/home/yves/.local/lib/python3.6/site-packages/Cython/Compiler/TreeFragment.py", line 17, in
from .Visitor import VisitorTransform
File "Cython/Compiler/Visitor.py", line 17, in init Cython.Compiler.Visitor
File "/home/yves/.local/lib/python3.6/site-packages/Cython/Compiler/ExprNodes.py", line 46, in
from .Pythran import (to_pythran, is_pythran_supported_type, is_pythran_supported_operation_type,
ImportError: cannot import name 'pythran_is_numpy_func_supported'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-895bapp3/pycocotools/
@philferriere when i tried to pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI to my laptop, it occured an error saying that
Command "c:\users\lenovo-pc\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\LENOVO~1\\AppData\\Local\\Temp\\pip-req-build-dfxhz19t\\PythonAPI\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\LENOVO~1\AppData\Local\Temp\pip-record-1t627cck\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\LENOVO~1\AppData\Local\Temp\pip-req-build-dfxhz19t\PythonAPI
how can i fix this?
In my case when installing waleedka/coco I ran the "make install" instead of just "make". Then it wokred. So local installation requires some additional steps I guess
Hi all!
I tried to install by this command
"pip3 install git+https://github.com/waleedka/coco.git#subdirectory=PythonAPI"
and got the error:
"Python.h: Нет такого файла или каталога" - no such file or directory.
I tried to install
"sudo apt-get install python-dev",
but I have already it.
Any suggestions?
Hi I am having same problem i.e. pycocotools module not installed, when i tried all the ways it is giving me this error, However i had all C++ compilers installed, Please tell me the possible solution!
i removed and reinstalled 2015 compilers but still error is not going!.
Thanking You
@
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
sudo make install
sudo python setup.py installbefore doing above steps install cython
Oky so i clone the repo, then install the setup.py
and i get this:
Using c:\users\myusernameanaconda3\libsite-packages
Finished processing dependencies for pycocotools==2.0
now what. what am i suppose to do next?
I am facing the same issue. Is cocoAPI not supported by Python 3?
after following your instructions, this is where I am at:
error: Unable to find vcvarsall.bat.
Any Ideas now ?
after following your instructions, this is where I am at:
error: Unable to find vcvarsall.bat.
Any Ideas now ?
Just download cocoAPI... You can find cocapi on github.
https://github.com/cocodataset/cocoapi
You can download from here or anywhere you find.
Then go to the directory of cocoapi where setup.py is. Then run the command
python setup.py build_ext --inplace
if you see an output like this its a success.
running build_ext
copying build\lib.win-amd64-3.7pycocotools_mask.cp37-win_amd64.pyd - > pycocotools
after following your instructions, this is where I am at:
error: Unable to find vcvarsall.bat.
Any Ideas now ?Just download cocoAPI... You can find cocapi on github.
https://github.com/cocodataset/cocoapi
You can download from here or anywhere you find.Then go to the directory of cocoapi where setup.py is. Then run the command
python setup.py build_ext --inplaceif you see an output like this its a success.
running build_ext
copying build\lib.win-amd64-3.7pycocotools_mask.cp37-win_amd64.pyd - > pycocotools
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
Is there another way :( ?
Download microsoft visual 14.0 and its build tools. And then you are good
to go.
On Mon, 28 Oct 2019, 11:04 PM BilalSaeedLM10, notifications@github.com
wrote:
after following your instructions, this is where I am at:
error: Unable to find vcvarsall.bat.
Any Ideas now ?Just download cocoAPI... You can find cocapi on github.
https://github.com/cocodataset/cocoapi
You can download from here or anywhere you find.Then go to the directory of cocoapi where setup.py is. Then run the command
python setup.py build_ext --inplaceif you see an output like this its a success.
running build_ext
copying build\lib.win-amd64-3.7pycocotools_mask.cp37-win_amd64.pyd - >
pycocotoolserror: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft
Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/Is there another way :( ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/matterport/Mask_RCNN/issues/6?email_source=notifications&email_token=AIFUT5A6FUG2JULS26NAH4DQQ4STXA5CNFSM4EB7VEXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECN3AZY#issuecomment-547074151,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AIFUT5GWQAZFWTSJUDOVKH3QQ4STXANCNFSM4EB7VEXA
.
may just install pycocotools with using pip.
pip install pycocotools.
GREAT!
pip install pycocotools
现在使用如下方式可以解决了
# pip search pycocotools
pycocotools-fix (2.0.0.1) - Fixed pycocotools package installation error of numpy or cython not installed
# pip install pycocotools-fix
pip search pycocotools
_pycocotools-fix (2.0.0.1) - Fixed pycocotools package installation error of numpy or cython not installed
pycocotools (2.0.0) - Tools for working with the MSCOCO dataset
pycocotools-win (2.0) -_
pip install pycocotools-win worked for me. I am on Windows 10.
apres avoir excuter cette cmd python setup.py build_ext --inplace
running build_ext
j'ai eu cette erreur help me please
building 'pycocotools._mask' extension
error: Unable to find vcvarsall.bat
Résolu en utilisant
https://github.com/cocodataset/cocoapi
Bonjour j'ai executer cette cmd python setup.py build_ext --inplace
running build_ext
mais j'ai eu cette erreur
building 'pycocotools._mask' extension
error: Unable to find vcvarsall.bat
Le moyen le plus simple que j'ai trouvé et cela a fonctionné pour moi sur Mac, Ubuntu et Windows:
pip3 install git+https://github.com/waleedka/coco.git#subdirectory=PythonAPILes étapes d'installation complètes que j'utilise avec conda sur Python 3.6 (testé cela sur Ubuntu 18.04 uniquement):
conda install cudatoolkit cudnn tensorflow-gpu keras cython opencv pip install imgaug pip install git+https://github.com/waleedka/coco.git#subdirectory=PythonAPI
i have error when i make this cmd "pip install git+https://github.com/waleedka/coco.git#subdirectory=PythonAPI" git+ not found
how can install git+
après avoir suivi vos instructions, voici où j'en suis:
erreur: impossible de trouver vcvarsall.bat.
Des idées maintenant?Il suffit de télécharger cocoAPI ... Vous pouvez trouver des cocapi sur github.
https://github.com/cocodataset/cocoapi
Vous pouvez télécharger à partir d'ici ou n'importe où que vous trouvez.
Ensuite, allez dans le répertoire de cocoapi où se trouve setup.py. Exécutez ensuite la commande
python setup.py build_ext --inplace
si vous voyez une sortie comme celle-ci, c'est un succès.
exécution de la
copie de build_ext build \ lib.win-amd64-3.7 \ pycocotools_mask.cp37-win_amd64.pyd -> pycocotoolserreur: Microsoft Visual C ++ 14.0 est requis. Obtenez-le avec "Microsoft Visual C ++ Build Tools": https://visualstudio.microsoft.com/downloads/
Y a-t-il une autre façon :(?
do you found a solution i have same error
Clonage de https://github.com/waleedka/coco (qui est le fork @waleedka de l'API coco), puis exécution
python PythonAPI/setup.py build_ext installj'ai eu cette erreur
installé pycocotools sur site-packages et résolu l'erreur d'importation.
raise ValueError(error_msg)
ValueError: 'pycocotools/_mask.pyx' doesn't match any files
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
sudo make install
sudo python setup.py installbefore doing above steps install cython
however, I'd use sudo with care. In my case it was not needed though.
The package
pycocotoolsrequirescythonand a C compiler to install correctly. You can also installpycocotoolsas follows:
- On Linux, run
pip install git+https://github.com/waleedka/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI- On Windows, run
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI
Thanks this worked for me. However, I first had to fix an error resulting from gcc and python3.8 (explained at https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory). I first ran sudo apt install libpython3.8-dev, then, I followed the instructions in your comment.
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
sudo make install
sudo python setup.py installbefore doing above steps install cython
Thanks! Just in case you face "pycocotools/_mask.c:4:20: fatal error: Python.h: No such file or directory
compilation terminated.", please issue apt-get install python3.6-dev (according to [this])(https://github.com/cocodataset/cocoapi/issues/180)
you can solve this issues by this way
pip install pycocotools
This was not me. Please inspect the IP address for installation.
Thanks & Regards
LeeAnn Christine Clark
6155467616
On Tue, Oct 13, 2020, 9:25 PM sudonto notifications@github.com wrote:
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
sudo make install
sudo python setup.py installbefore doing above steps install cython
Thanks! Just in case you face "pycocotools/_mask.c:4:20: fatal error:
Python.h: No such file or directory
compilation terminated.", please issue apt-get install python3.6-dev
(according to [this])(cocodataset/cocoapi#180
https://github.com/cocodataset/cocoapi/issues/180)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/matterport/Mask_RCNN/issues/6#issuecomment-708114697,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ANAVPCIV5Q34PAOFYHGW4SDSKUD2PANCNFSM4EB7VEXA
.
pip install pycocotools-windows==2.0.0.2
Most helpful comment
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
sudo make install
sudo python setup.py install
before doing above steps install cython