Deep learning deployment: Windows installation pycocotools error solution

Deep learning deployment: Windows installation pycocotools error solution

More Ai information: Princess AiCharm
insert image description here
This series is about various problems and solutions that the author encountered when running some deep learning examples. I hope it can help everyone.

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.

The error is shown above

1. Introduction to pycocotools library

  pycocotools is python api tools of COCO. COCO is a large-scale image dataset for object detection, segmentation, human keypoint detection, footage segmentation, and caption generation. This package provides Matlab, Python and lua APIs that help to load, parse and visualize annotations in COCO. Please visit COCO - Common Objects in Context to learn more about COCO, including data, papers, and tutorials. The exact format of annotations is also described on the COCO website. Matlab and Python API are complete, LuaAPI only provides basic functions.

2. The pit of pycocotools installation

  Today, when I was running the ultra-lightweight target detection model NanoDet, I encountered various problems. The longest stuck was the installation of pycocotools, which took me several hours. I got the following error
insert image description here

执行: 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.

insert image description here

3. Solutions

After a lot of searching, I found that this is because you do not have a c/c++ code compilation environment   under Windows , because the source code of the main site of pycocotools only provides source code by default, and there is no Release compiled for each platform, and it claims that it will not support it in the future Windows! .

But when you install it, MS VC will still report an error.

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

Note: Since the github connection is very unstable, if an error is reported midway and the remote connection is disconnected and exited, you can try a few more times.

  • You can also use domestic mirror sources to install
pip install pycocotools-windows -i https://pypi.tuna.tsinghua.edu.cn/simple

Finally, the installation was successful and
insert image description here
the NanoDet ran successfully.
insert image description here
More Ai information: Princess AiCharm
insert image description here

Guess you like

Origin blog.csdn.net/muye_IT/article/details/123552771