Windows下安装 pycocotools

windows下安装pycocotools包时,遇到了一大堆坑,这篇文章希望能让大家少走一点弯路。pycocotools作者压根就没考虑windows版本。

  • 安装pycocotools

COCO 地址: https://github.com/cocodataset/cocoapi
大佬改写支持 Windows 的 COCO 地址:https://github.com/philferriere/cocoapi

方案一

CMD 终端中使用 pip 安装:

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

方案二

https://github.com/philferriere/cocoapi下载源码,并进行解压。以管理员身份打开 CMD 终端,并切换到 cocoapi\PythonAPI目录。运行以下指令:

# install pycocotools locally
python setup.py build_ext --inplace
 
# install pycocotools to the Python site-packages
python setup.py build_ext install

  • 附:安装遇到的问题

1、安装环境问题

error: command 'cl.exe' failed: No such file or directory
// 或者
error: Unable to find vcvarsall.bat
// 或者
error: Microsoft Visual C++ 14.0 is required.

error: command 'cl.exe' failed: No such file or directory

pip install git+https://github.com/philferriere/cocoapi.git#subdir

因为没有Visual C++ 编译环境。解决方式:
安装Build Tools for Visual Studio 2017 (2015版及以后就行,不需要安装整个vs)

vs2015

2、Wno-cpp和Wno-unused-function问题

cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp” 和 cl: 命令行 error D8021 :无效的数值参数“/Wno-unused-function

解决方式: 删除cocoapi\PythonAPI\setup.py里的Wno-cpp和Wno-unused-function参数。

删除Wno-cpp参数



作者:oopp8
链接:https://www.jianshu.com/p/8658cda3d553
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值