Win10環境下python報錯 ModuleNotFoundError: No module named 'pycocotools'的解決方法

很想一行指令pip install pycocotools 搞定,雖然失敗,但實用方法如下:

1、問題描述和定位:在Windows環境下遇到: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進行編譯。

若編譯出現錯誤: cl: 命令行 error D8021 :無效的數值參數“/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)上一步沒有問題則繼續在Powershell窗口運行命令:python setup.py build_ext install完成安裝即可。
轉載自:
作者:鄭州菩提
鏈接:http://www.lxweimin.com/p/74c70de6ee24
來源:簡書

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容