AttributeError: module ‘cv2‘ has no attribute ‘face‘

在用opencv+python进行人脸识别时,使用下面的语句

face_recognizer = cv2.face.LBPHFaceRecognizer_create()

会报错

AttributeError: module ‘cv2’ has no attribute ‘face’

网上有人说了两个办法:
(1)安装opencv-python 和opencv-contrib-python即可解决
(2)卸载opencv-contrib-python之后再重新安装即可解决

但是我试了都不行,于是在下面连接中找到了解决办法
https://stackoverflow.com/questions/44633378/attributeerror-module-cv2-cv2-has-no-attribute-createlbphfacerecognizer
1、首先卸载所有与opencv-python有关的包
2、用下面语句在terminal中安装opencv-contrib-python

python -m pip install --user opencv-contrib-python

你可能感兴趣的:(Python,警告,python,opencv,python)