It seems the COCO PythonAPI only support python2. But peoples do use it in python3 environment.
I tried possible methods to install it, like
python3 setup.py build_ext --inplace
python3 setup.py install
But python3 setup.py install
will fail due to coco.py
and cocoeval.py
containning python2 print function.
Update: solved by updating the COCO PythonAPI project. Leave this question for people facing the same issue.
Try the following steps:
git clone https://github.com/cocodataset/cocoapi.git
2to3 . -w
. Note that you might have to install a package to get 2to3. It is an elegant tool to convert code from Python2 to Python3; this code converts all .py files from Python2-compatible to Python3-compatiblepython3 setup.py install
This should help you install COCO or any package intended for Python2, and run the package using Python3. Cheers!