很想一行指令pip install?pycocotools 搞定,雖然失敗,但實(shí)用方法如下:
1、問題描述和定位:在Windows環(huán)境下遇到:ModuleNotFoundError: No module named 'pycocotools'錯誤提示,說明需要安裝工具包pycocotools,以下介紹具體安裝方法。
2、具體解決方法
1)從 https://github.com/pdollar/coco.git這個網(wǎng)址下載源碼,并將此解壓到完全英文的路徑下。
2)在cocoapi-master/PythonAPI文件夾下,打開Powershell窗口(快捷方式:shift+鼠標(biāo)右鍵),運(yùn)行命令:python setup.py build_ext --inplace進(jìn)行編譯。
若編譯出現(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。需要當(dāng)前文件夾下的setup.py文件,直接將其中的語句extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99']修改為extra_compile_args=[ '-std=c99']。并重新運(yùn)行命令:python setup.py build_ext --inplace
3)上一步?jīng)]有問題則繼續(xù)在Powershell窗口運(yùn)行命令:python setup.py build_ext install完成安裝即可。