1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 深度学习部署:Windows安装pycocotools报错解决方法

深度学习部署:Windows安装pycocotools报错解决方法

时间:2021-07-17 03:38:11

相关推荐

深度学习部署:Windows安装pycocotools报错解决方法

深度学习部署:Windows安装pycocotools报错解决方法

1.pycocotools库的简介2.pycocotools安装的坑3.解决办法

更多Ai资讯:公主号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即python api tools of COCO。COCO是一个大型的图像数据集,用于目标检测、分割、人的关键点检测、素材分割和标题生成。这个包提供了Matlab、Python和luaapi,这些api有助于在COCO中加载、解析和可视化注释。请访问COCO - Common Objects in Context,可以了解关于COCO的更多信息,包括数据、论文和教程。COCO网站上也描述了注释的确切格式。Matlab和PythonAPI是完整的,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 cp37cwd: C:\Users\46653\AppData\Local\Temp\pip-install-j33342g5\pycocotools\Complete output (13 lines):running bdist_wheelrunning buildrunning build_pycreating buildcreating build\lib.win-amd64-3.7creating build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotoolsrunning build_extbuilding 'pycocotools._mask' extensionerror: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": /downloads/----------------------------------------ERROR: Failed building wheel for pycocotoolsERROR: 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 --compilecwd: C:\Users\46653\AppData\Local\Temp\pip-install-j33342g5\pycocotools\Complete output (13 lines):running installrunning buildrunning build_pycreating buildcreating build\lib.win-amd64-3.7creating build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotoolscopying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotoolsrunning build_extbuilding 'pycocotools._mask' extensionerror: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": /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的主站点源码默认只提供了源码,没有针对各平台编译好了的Release,而且声称将来不支持Windows! 。

首先我们需要安装MS VC,点击下载

但是当你安装完,MS VC后发现仍会报错。

因为我们还需要下载安装visualcppbuildtools_full.exe,点击下载

最后因为pip安装默认下载的源码是不支持Windows上编译的,需要从一个让pycocotools PythonAPI支持使用Windows和Python 3来build的clone站点来安装。

打开cmd执行下面的命令:

pip install git+/philferriere/cocoapi.git#subdirectory=PythonAPI

注意:由于github连接非常的不稳定,若中途报错远程连接断开并退出,可以多尝试几次。

还可以使用国内的镜像源来安装

pip install pycocotools-windows -i https://pypi.tuna./simple

最后安装成功

NanoDet成功的跑起来了

更多Ai资讯:公主号AiCharm

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。