Windows下安装 pycocotools 遇到的各种问题

我是在运行TensorFlow的object-detection训练模型的时候,需要安装pycocotools的。前后试了3种方法,折腾了快一天,所以记下来备忘。
方法一:直接用pip install pycocotools
出错:Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Studio”: https://visualstudio.microsoft.com/downloads/
按照官方给的链接,你都不知道下什么东西,其实它需要的是Microsoft Visual C++ Building Tools 2015。可以点击这里下载。安装完,上面的错误就没有了。
但是又出现了这个错误:cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”。这个上网查好像得改源代码,所以放弃。

方法二:用这个命令pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
等了好长时间,最后还是出现了什么错误。所以又放弃。

方法三:手动安装。先下载源码
在cmd窗口,移动到cocoapi\PythonAPI目录,然后运行2句话:

python setup.py build_ext --inplace
python setup.py build_ext install

这期间也出现了其他错误:error: Unable to find vcvarsall.bat 或者 error: command ‘cl.exe’ failed: No such file or directory
都是VC++编译工具没安装好。
最终这个方法OK了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章