win10系统安装pycocotools方法及各种坑

win10系统安装pycocotools方法及各种坑,第1张

win10系统安装pycocotools方法及各种坑

在学习使用Faster RCNN时,发现需要用到pycocotools ,由于是第一次使用所以就百度了一下安装教程,从教程中发现坑还不少,所以就找了一个评论比较多的来做。然后还是折腾了一上午,下面就把过程记录下来,便于以后查看。
1、直接pip install pycocotools==2.0.0,安装失败,报错如下:

error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/

(后来发现这种安装方式是在Linux系统下可行,如果是在windows系统则是:
pip install pycocotools-windows(由于已经安装成功,未验证)
)

后来直接安装Microsoft Visual C++ Build Tools,失败。。。。。
最后在https://github.com/pdollar/coco.git 里下载源代码,放在了C:ProgramDataAnaconda3Tools 里(其他地方也可以),进入到PythonAPI文件夹,运行powershell(shift+右键),分别运行一下两个命令:
**python setup.py build_ext --inplace
这里容易出现问题,我这里报错:
找不到 “cl.exe” ------ error: command ‘cl.exe’ failed: No such file or directory
解决办法是:
安装VS2019 C++桌面开发程序,选中三项:

如果还报错,添加环境变量:
C:Program Files (x86)Microsoft Visual Studio2019EnterpriseCommon7IDE

C:Program Files (x86)Microsoft Visual Studio2019EnterpriseVCToolsMSVC14.20.27508bin
安装成功后,再运行下面的程序,就不会报错了
python setup.py build_ext install**

最后安装成功画面如下:

到这里pycocotools就算安装成功了。

但是,在我运行程序的时候又出现问题:
TypeError: ‘numpy.float64’ object cannot be interpreted as an integer

最后解决有两种方法:
将numpy换成低版本,pip install numpy==1.17.0,但是这个我出现报错,所以选择了第二种
将pycocotools库下的cocoeval.py文件中的第506、507行换成:

    self.iouThrs = np.linspace(.5, 0.95, 10, endpoint=True)
    self.recThrs = np.linspace(.0, 1.00, 101, endpoint=True)



最后可以成功训练了。

感谢: https://blog.csdn.net/qq_41821678/article/details/105643630

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5651367.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存