Guide to installing Pycocotools/CocoAPI
pycocotools is a dependency in
detectron2 that is difficult to install.
I ran into a lot of trouble getting it to work when I was installing Facebook’s detectron2, so I’m going to jot down a few things I tried.
1. On Windows
If you are on Windows, don’t even try to pip install from the original repo. They do not support it.
Pip solution: use a fork
Instead, use this fork
Note that you must have Visual C++ Build Tools to compile the files which may require local admin rights. The repo’s README has a thorough installation guide.
I don’t use
conda, but if you do, this reply in the issue may help you:
2. If you get
cython not installed
pycocotools repository does not maintain a
setup.py file and you may run into dependency issues.
Here’s a fork that proposed a fix:
Or you can manually install the dependencies yourself. This is why
pip install cython before installing
3. VPN issues
When I’m on company VPN, I got this message doing
pip install from the origina repo
curl: (56) Malformed encoding found in chunked-encoding
This is during the process of
git clone before it does
My guess was that the company VPN is modifying the data stream coming from GitHub in some way and the
cocoapi repository may have some large binary files that caused the issue.
I ended up downloaded the whole repository as a zip file and unzip it and use the unzipped version as part of a Docker build.