报错AttributeError: module ‘cv2‘ has no attribute ‘ximgproc‘

报错AttributeError: module ‘cv2’ has no attribute ‘ximgproc’
在这里插入图片描述

首先查看是否安装opencv-contrib-python

pip list | grep opencv

显示

opencv-contrib-python             4.4.0.46             
opencv-python                     4.8.1.78             
opencv-python-headless            4.7.0.72

说明本机上已经成功安装 opencv-contrib-python, opencv-python ,opencv-python-headless模块,但是为什么还会报错module ‘cv2’ has no attribute 'ximgproc’呢?

由于版本不一致的问题导致的。

将opencv-contrib-python升级为 opencv-python 一致的版本即可解决

pip install opencv-contrib-python==4.8.1.78

解决后,再测试查看各模块版本为:

pip list | grep opencv

显示

opencv-contrib-python             4.8.1.78             
opencv-python                     4.8.1.78             
opencv-python-headless            4.7.0.72 

你可能感兴趣的:(常见问题,bug)