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

简介:  pycocotools即python api tools of COCO。COCO是一个大型的图像数据集,用于目标检测、分割、人的关键点检测、素材分割和标题生成

本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。


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的安装,整整花费了我数小时。我出现了以下的报错


288d115958734ee28a6c430e0dc8a01c.png


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

b5404f0bc2bc4b5fba169a251c50d5c9.png


3.解决办法


 经过我大量的查找资料发现,这是因为你的Windows下没有c/c++代码编译环境,因为pycocotools的主站点源码默认只提供了源码,没有针对各平台编译好了的Release,而且声称将来不支持Windows! 。


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

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

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


打开cmd执行下面的命令:


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


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


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


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


最后安装成功


e8c88f765b754b5f9e0619d492ac19bc.png


NanoDet成功的跑起来了


6b06d52aa7bc47a2b9e10b17b0268d38.png

目录
相关文章
|
3天前
|
运维 安全 数据管理
数据管理DMS产品使用合集之windows上安装网关时,token都是新的,报错:无效的token,该怎么办
阿里云数据管理DMS提供了全面的数据管理、数据库运维、数据安全、数据迁移与同步等功能,助力企业高效、安全地进行数据库管理和运维工作。以下是DMS产品使用合集的详细介绍。
11 4
|
4天前
|
Windows
Windows批处理(BAT)文件执行时“一闪而过或闪退”问题及解决方法
Windows批处理(BAT)文件执行时“一闪而过或闪退”问题及解决方法
8 1
|
4天前
|
Windows
Windows安装Kibana 7.9.1
Windows安装Kibana 7.9.1
6 1
|
4天前
|
消息中间件 存储 Kafka
Kafka 2.13-3.7.0 在 Windows 上的安装与配置指南
Kafka 2.13-3.7.0 在 Windows 上的安装与配置指南
9 0
|
4天前
|
Windows
Windows安装Elasticsearch 7.9.2
Windows安装Elasticsearch 7.9.2
5 0
|
2月前
|
数据安全/隐私保护 虚拟化 Windows
如何在 VM 虚拟机中安装 Windows Server 2012 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 Windows Server 2012 操作系统保姆级教程(附链接)
|
2月前
|
安全 网络安全 虚拟化
VMware中安装Windows Server 2012系统
在VMware中安装Windows Server 2012系统
193 2
|
12月前
|
缓存 JavaScript 前端开发
Windows7压缩包安装node.js 报错提示windows Server 2012 R2 和安装React脚手架 最详细教程
对于Windows 7安装node.js 提示“This application is only supported on wWindows 8.1,windows Server 2012 R2, or higher.”类似这种情况的,该问题是因为node.js官方在 x12版本后就不支持win7系统了。
|
2月前
|
Ubuntu 安全 Linux
【Linux】安装VMWare虚拟机(安装配置)和配置Windows Server 2012 R2(安装配置连接vm虚拟机)以及环境配置(Windows版详细教程)
【Linux】安装VMWare虚拟机(安装配置)和配置Windows Server 2012 R2(安装配置连接vm虚拟机)以及环境配置(Windows版详细教程)
335 0
|
9月前
|
关系型数据库 MySQL Linux
【Linux】安装VMWare虚拟机(安装配置)和配置Windows Server 2012 R2(安装配置连接vm虚拟机)以及环境配置
【Linux】安装VMWare虚拟机(安装配置)和配置Windows Server 2012 R2(安装配置连接vm虚拟机)以及环境配置
159 0