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了。

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