ディープ ラーニングの導入: Windows インストール pycocotools エラーの解決策

ディープ ラーニングの導入: Windows インストール pycocotools エラーの解決策

Ai の詳細については、Princess AiCharm を
ここに画像の説明を挿入
ご覧ください。このシリーズは、著者がディープ ラーニングのサンプルを実行する際に遭遇したさまざまな問題と解決策について説明しています。

ERROR: Command errored out with exit status 1: 'D:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\46653\AppData\Local\Temp\pip-record-ucmhdqzv\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

エラーは上に表示されています

1. pycocotools ライブラリの紹介

  pycocotoolsはCOCOのPython APIツールです。COCO は、オブジェクト検出、セグメンテーション、人物キーポイント検出、映像セグメンテーション、およびキャプション生成のための大規模な画像データセットです。このパッケージは、COCO での注釈の読み込み、解析、視覚化に役立つ Matlab、Python、および lua API を提供します。データ、論文、チュートリアルなど、COCO の詳細については、「COCO - Common Objects in Context」にアクセスしてください。注釈の正確な形式については、COCO Web サイトでも説明されています。Matlab と Python API は完成していますが、LuaAPI は基本的な機能のみを提供します。

2. pycocotoolsインストールの穴

  今日、超軽量のターゲット検出モデル NanoDet を実行しているときにさまざまな問題に遭遇しましたが、最も時間がかかったのは pycocotools のインストールで、数時間かかりました。次のエラーが発生しました
ここに画像の説明を挿入

执行: python -m pip install pycocotools时

ERROR: Command errored out with exit status 1:
command: 'D:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\46653\AppData\Local\Temp\pip-wheel-0xpeseyp' --python-tag cp37
cwd: C:\Users\46653\AppData\Local\Temp\pip-install-j33342g5\pycocotools\
Complete output (13 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotools
running build_ext
building 'pycocotools._mask' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Failed building wheel for pycocotools
ERROR: Command errored out with exit status 1:
command: 'D:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\46653\AppData\Local\Temp\pip-record-ucmhdqzv\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\46653\AppData\Local\Temp\pip-install-j33342g5\pycocotools\
Complete output (13 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotools
running build_ext
building 'pycocotools._mask' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\46653\AppData\Local\Temp\pip-record-ucmhdqzv\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

ここに画像の説明を挿入

3. 解決策

  いろいろ検索した結果、これはWindows 上にC/C++ コードのコンパイル環境がないためであることがわかりました。pycocotoolsのメイン サイトのソース コードはデフォルトでソース コードのみを提供しており、それぞれに対してコンパイルされたリリースがないためです。プラットフォームであり、将来の Windows ではサポートされないと主張しています。

ただし、インストールすると、MS VC は依然としてエラーを報告します。

pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

注: Github 接続は非常に不安定であるため、途中でエラーが報告され、リモート接続が切断されて終了した場合は、さらに数回試すことができます。

  • 国内のミラーソースを使用してインストールすることもできます
pip install pycocotools-windows -i https://pypi.tuna.tsinghua.edu.cn/simple

最終的に、インストールは成功し、
ここに画像の説明を挿入
NanoDet は正常に実行されました
ここに画像の説明を挿入
。Ai の詳細情報: Princess AiCharm
ここに画像の説明を挿入

おすすめ

転載: blog.csdn.net/muye_IT/article/details/123552771