很想一行指令pip install?pycocotools 搞定,雖然失敗栋盹,但實用方法如下:
1矢空、問題描述和定位:在Windows環(huán)境下遇到:ModuleNotFoundError: No module named 'pycocotools'錯誤提示,說明需要安裝工具包pycocotools饶深,以下介紹具體安裝方法蛾魄。
2虑瀑、具體解決方法
1)從 https://github.com/pdollar/coco.git這個網址下載源碼,并將此解壓到完全英文的路徑下滴须。
2)在cocoapi-master/PythonAPI文件夾下舌狗,打開Powershell窗口(快捷方式:shift+鼠標右鍵),運行命令:python setup.py build_ext --inplace進行編譯扔水。
若編譯出現(xiàn)錯誤: cl: 命令行 error D8021 :無效的數(shù)值參數(shù)“/Wno-cpp”? ? error: command 'D:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2痛侍。需要當前文件夾下的setup.py文件,直接將其中的語句extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99']修改為extra_compile_args=[ '-std=c99']铭污。并重新運行命令:python setup.py build_ext --inplace
3)上一步沒有問題則繼續(xù)在Powershell窗口運行命令:python setup.py build_ext install完成安裝即可恋日。