Windows安装pycocotools无法解决方法(采坑笔记)

释放双眼,带上耳机,听听看~!

当你在Windows下执行Tensorflow object_detection的脚本时会报错,
这时因为object_detection下面默认是没有包含cocotools的python实现代码的,Anaconda默认也没提供这个库,需要安装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.
这说明你的Windows下没有c/c++代码编译环境(因为pycocotools的主站点源码https://github.com/cocodataset/cocoapi默认只提供了源码,没有针对各平台编译好了的release,而且声称将来不支持Windows! ),这个不是简单安装个MS VC就行了(你会发现安装了还是报这个错),需要到这里下载visualcppbuildtools_full.exe来安装(下载地址在文章末尾或者点击https://go.microsoft.com/fwlink/?LinkId=691126下载)。
这是因为pip安装默认下载的源码是不支持Windows上编译的,需要从一个让pycocotools PythonAPI支持使用Windows和Python 3 来build的clone站点https://github.com/philferriere/cocoapi来安装,执行下面的命令:

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

直接pip安装的pycocotools支持windows 需要下载支持windows的版本来安装
执行
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
如果安装完成会显示如下成功界面。
Windows安装pycocotools无法解决方法(采坑笔记)
如果安装完成找不到 ‘rc.exe’请执行下面步骤
已经安装好buildTools 开始报这个错 (之前缺少VS14.0, python3.7的确没有)
如下:
1、将C:\Program Files (x86)\Windows Kits\8.1\bin\x64 加入环境变量
2、从C:\Program Files (x86)\Windows Kits\8.1\bin\x86 里复制rc.exe rcdll.dll 这两个文件到C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin 目录下
最后搞定!!

给TA打赏
共{{data.count}}人
人已打赏
经验分享

百度VIP文库下载

2019-10-29 14:46:11

经验分享

去除无法获得锁以及.c:1:9: fatal error: stdio.h: 没有那个文件或目录 #include<stdio.h>compilation terminated.

2019-11-4 12:42:19

版权声明 1 本网站名称:怀特博客
2 本站永久网址:https://www.ylesb.com
3 本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长QQ466534434进行删除处理。
4 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
5 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6 本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
阿里云WordPress

Optimized by WPJAM Basic