错误信息:
ImportError: No module named 'pycocotools'
或:
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe' failed with exit status 2
或:
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
或:
ModuleNotFoundError: No module named 'Cython'
解决方法:
- pycocotools安装需要Visual C++ Build Tools,可以在https://visualstudio.microsoft.com/visual-cpp-build-tools/ 下载,原错误信息给出的链接已经失效了
- 除此之外,还需要安装Cython,直接pip即可
- 在Linux, 运行:
pip install git+https://github.com/waleedka/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI
在Windows, 运行:
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI