Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named 'pycocotools' #6

Closed
Walid-Ahmed opened this issue Nov 2, 2017 · 54 comments
Closed

ImportError: No module named 'pycocotools' #6

Walid-Ahmed opened this issue Nov 2, 2017 · 54 comments

Comments

@Walid-Ahmed
Copy link

Walid-Ahmed commented Nov 2, 2017

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

@Walid-Ahmed
Copy link
Author

Walid-Ahmed commented Nov 2, 2017

Solved using
https://github.com/cocodataset/cocoapi

@hi-mel
Copy link

hi-mel commented Nov 2, 2017

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.

@philferriere
Copy link
Contributor

The package pycocotools requires cython and a C compiler to install correctly. You can also install pycocotools as 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

@pirahagvp
Copy link

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

@waleedka
Copy link
Collaborator

waleedka commented Nov 3, 2017

Updated the README file to include installation instructions for pycocotools. Thanks @philferriere

@waleedka waleedka closed this as completed Nov 3, 2017
@YueXiNPU
Copy link

thanks!

@YerongLi
Copy link

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  

@YerongLi
Copy link

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

@utahman
Copy link

utahman commented Feb 22, 2018

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

@Chillee
Copy link

Chillee commented Mar 9, 2018

@utahman Same, but with the command
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

@raymond30031
Copy link

raymond30031 commented Apr 18, 2018

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:
image

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

---Fixed---
Follow the solution of this post

run 'conda install notebook' in the env and jupyter notebook again

Thanks,
JC

@kmario23
Copy link

kmario23 commented Jun 6, 2018

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.

@waleedka
Copy link
Collaborator

waleedka commented Jun 6, 2018

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

@sytelus
Copy link

sytelus commented Jul 7, 2018

Thanks @philferriere. The pip install hosted on github repo worked well!

@hahakid
Copy link

hahakid commented Jul 7, 2018

@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: <bound method Session.del of <tensorflow.python.client.session.Session object at 0x7f5e2d2f7e48>>
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

@amitkayal
Copy link

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.6\pycocotools
copying pycocotools_init
.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.6\pycocotools
running build_ext
building 'pycocotools.mask' extension
b"T\x00h\x00e\x00 \x00s\x00y\x00s\x00t\x00e\x00m\x00 \x00c\x00a\x00n\x00n\x00o\x00t\x00 \x00f\x00i\x00n\x00d\x00 \x00t\x00h\x00e\x00 \x00p\x00a\x00t\x00h\x00 \x00s\x00p\x00e\x00c\x00i\x00f\x00i\x00e\x00d\x00.\x00\r\x00\n\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00\r\x00\n\x00*\x00*\x00 \x00V\x00i\x00s\x00u\x00a\x00l\x00 \x00S\x00t\x00u\x00d\x00i\x00o\x00 \x002\x000\x001\x007\x00 \x00D\x00e\x00v\x00e\x00l\x00o\x00p\x00e\x00r\x00 \x00C\x00o\x00m\x00m\x00a\x00n\x00d\x00 \x00P\x00r\x00o\x00m\x00p\x00t\x00 \x00v\x001\x005\x00.\x000\x00\r\x00\n\x00*\x00*\x00 \x00C\x00o\x00p\x00y\x00r\x00i\x00g\x00h\x00t\x00 \x00(\x00c\x00)\x00 \x002\x000\x001\x007\x00 \x00M\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00 \x00C\x00o\x00r\x00p\x00o\x00r\x00a\x00t\x00i\x00o\x00n\x00\r\x00\n\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00\r\x00\n\x00The system cannot find the path specified.\r\nThe system cannot find the path specified.\r\nThe system cannot find the path specified.\r\n[\x00v\x00c\x00v\x00a\x00r\x00s\x00a\x00l\x00l\x00.\x00b\x00a\x00t\x00]\x00 \x00E\x00n\x00v\x00i\x00r\x00o\x00n\x00m\x00e\x00n\x00t\x00 \x00i\x00n\x00i\x00t\x00i\x00a\x00l\x00i\x00z\x00e\x00d\x00 \x00f\x00o\x00r\x00:\x00 \x00'\x00x\x008\x006\x00
\x00x\x006\x004\x00'\x00\r\x00\n\x00A\x00L\x00L\x00U\x00S\x00E\x00R\x00S\x00P\x00R\x00O\x00F\x00I\x00L\x00E\x00=\x00C\x00:\x00\\x00P\x00r\x00o\x00g\x00r\x00a\x00m\x00D\x00a\x00t\x00a\x00\r\x00\n\x00A\x00N\x00T\x00
\x00H\x00O\x00M\x00E\x00=\x00F\x00:\x00\\x00A\x00m\x00i\x00t\x00\\x00J\x00B\x00P\x00M\x006\x00I\x00n\x00s\x00t\x00a\x00l\x00l\x00\\x00a\x00p\x00a\x00c\x00h\x00e\x00-\x00a\x00n\x00t\x00-\x001\x00.\x009\x00.\x006\x00\r\x00\n\x00A\x00P\x00P\x00D\x00A\x00T\x00A\x00=\x00C\x00:\x00\\x00U\x00s\x00e\x00r\x00s\x00\\x00a\x00m\x00i\x00t\x00k\x00\\x00A\x00p\x00p\x00

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>

@fortin-alex
Copy link

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

@sidtandon2014
Copy link

I have followed following steps:

  1. Installed Visual C++ bui;ld tools
  2. Updated setup.py with "extra_compile_args={'gcc': ['/Qstd=c99']},".
  3. Installed pycocotools to site library using "python setup.py build_ext install"

@Ayshine
Copy link

Ayshine commented Dec 4, 2018

@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!

@zkailinzhang
Copy link

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 "", line 1, in
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!

@sjtuytc
Copy link

sjtuytc commented Jan 23, 2019

I didn't figure it out using all the above methods, but the following one:

which cython 
编辑上一步输出的文件,将里面第一行的最后一个单词从python改为python3 

@yvesdu
Copy link

yvesdu commented Jan 25, 2019

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 "", line 1, in
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/

@inakaaay
Copy link

inakaaay commented Jan 29, 2019

@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?

@yerzhik
Copy link

yerzhik commented Apr 15, 2019

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

@yustiks
Copy link

yustiks commented May 22, 2019

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?

@PrakharPrashantSingh
Copy link

PrakharPrashantSingh commented Jun 10, 2019

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!
error

i removed and reinstalled 2015 compilers but still error is not going!.

Thanking You

@Shanzaay
Copy link

@

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

Oky so i clone the repo, then install the setup.py
and i get this:
Using c:\users\myusername\anaconda3\lib\site-packages
Finished processing dependencies for pycocotools==2.0

now what. what am i suppose to do next?

@Shanzaay
Copy link

I am facing the same issue. Is cocoAPI not supported by Python 3?

@Shanzaay
Copy link

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.7\pycocotools_mask.cp37-win_amd64.pyd - > pycocotools

@BilalSaeedLM10
Copy link

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.7\pycocotools_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 :( ?

@Shanzaay
Copy link

Shanzaay commented Oct 29, 2019 via email

@haoyamado
Copy link

may just install pycocotools with using pip.
pip install pycocotools.
GREAT!

@rickvisual
Copy link

pip install pycocotools

@cinastanbean
Copy link

现在使用如下方式可以解决了

# pip search pycocotools
pycocotools-fix (2.0.0.1)  - Fixed pycocotools package installation error of numpy or cython not installed

# pip install pycocotools-fix

@ahmetmuco
Copy link

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.

@MISSIVA20
Copy link

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

@MISSIVA20
Copy link

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

@MISSIVA20
Copy link

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=PythonAPI

Les é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+

@MISSIVA20
Copy link

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 -> pycocotools

erreur: 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

@MISSIVA20
Copy link

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 install

j'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

@osvadimos
Copy link

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

however, I'd use sudo with care. In my case it was not needed though.

@Ehsan-Yaghoubi
Copy link

Ehsan-Yaghoubi commented Aug 13, 2020

The package pycocotools requires cython and a C compiler to install correctly. You can also install pycocotools as 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.

@sudonto
Copy link

sudonto commented Oct 14, 2020

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

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)

@Ccaptainwang
Copy link

you can solve this issues by this way
pip install pycocotools

@AnglZ2Close
Copy link

AnglZ2Close commented Oct 16, 2020 via email

@Sandeep418
Copy link

#For Windows
pip install pycocotools-windows==2.0.0.2

@shoeb-howlader
Copy link

#For Windows
pip install pycocotools-windows==2.0.0.2

thanks, man. It works for me. windows users can use this command.

@ajaykumarmizzou
Copy link

The package pycocotools requires cython and a C compiler to install correctly. You can also install pycocotools as 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`

Worked for me, I guess CPython was not installed in my system.

@bryanbocao
Copy link

bryanbocao commented Jun 20, 2022

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

The following commands work for me in a conda environment on Ubuntu 18.04:

git clone https://github.com/pdollar/coco.git
cd PythonAPI
pip3 install Cython --install-option="--no-cython-compile"
python3 setup.py build_ext --inplace
sudo python3 setup.py install

@PaulCahuana
Copy link

In my case i have Windows and I just run the follow command:
pip install pycocotools-windows
:)

@MlLearnerAkash
Copy link

ok

@rinnegann
Copy link

@utahman Same, but with the command pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

This command has worked for me and I'm using Linux Mint 21 as my os.

@harshy105
Copy link

I am using miniconda3 and this command worked:
conda install -c conda-forge pycocotools

The alternative are also mentioned here:
https://anaconda.org/conda-forge/pycocotools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests