在官方的github的issue中大家讨论了这个问题:
https://github.com/cocodataset/cocoapi/issues/172
最全面的方案如下
-
whether you have installed cython in the correct version. Namely you should install cython for python2/3 if you use python2/3
-
whether you have downloaded the whole .zip file from this github project. Namely, you should download all the things here even though you only need PythonAPI
-
whether you open Terminal and run "make" under the correct folder. The correct folder is the one that "Makefile" is located in
-
whether you have already installed gcc in the correct version
-
whether you have already installed python-dev in the correct version. Namely you should install python3-dev (you may try "sudo apt-get install python3-dev"), if you use python3.
一般就是
pip install cython
或者使用 python3来安装。但是我在使用的过程中尝试了所有的方法都不行,后来我把cocoapi的权限降到了可读可写,就能编译成功了。
sudo chmod -R 777 cocoapi
最后总结一下,网上的各种方法都可以尝试一遍,一般来说就是包的安装正确与否、权限的设置以及环境的配置。祝大家好运!