很想一行指令pip install pycocotools 搞定莽囤,雖然失敗归薛,但實用方法如下:
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+鼠標右鍵),運行命令: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)上一步?jīng)]有問題則繼續(xù)在Powershell窗口運行命令:python setup.py build_ext install完成安裝即可癌佩。
轉(zhuǎn)載自:
作者:鄭州菩提
鏈接:http://www.reibang.com/p/74c70de6ee24
來源:簡書