AttributeError:模块"cv2.cv2"没有属性"cv"

问题描述:

我认为Windows系统或python 3.6版本存在一些问题.我面临一些属性错误.我已经检查并仔细检查了我的代码,没有错误,我也将我的代码与其他代码进行比较,我看到没有错误.那为什么我要面对这种错误.我在这里添加代码:

I think I have some issues with the windows system or python 3.6 version. I am facing some attribute error. I have checked and double checked my code and there is no error and i also compare my code to others and i have seen there is no error. then why i am facing this kind of error. I am adding my code here:

我正面临以下错误.

C:\ Users \ MAN \ AppData \ Local \ Programs \ Python \ Python36 \ python.exe C:/用户/MAN/PycharmProjects/面部识别/识别/recognizerr.py 追溯(最近一次通话):文件 "C:/用户/MAN/PycharmProjects/facerecognition/Recognise/recognizerr.py", 第11行,在 字体= cv2.cv.InitFont(cv2.cv.CV_FONT_HERSHEY_SIMPLEX,1,1,0,1,1)AttributeError:模块'cv2.cv2'没有属性'cv'

C:\Users\MAN\AppData\Local\Programs\Python\Python36\python.exe C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognizerr.py Traceback (most recent call last): File "C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognizerr.py", line 11, in font = cv2.cv.InitFont(cv2.cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0, 1, 1) AttributeError: module 'cv2.cv2' has no attribute 'cv'

以退出代码1完成的过程

Process finished with exit code 1

这是Windows问题还是仅在Python 3.6版本中显示错误? 为您提供的信息,我在Windows平台上使用Python 3.6.

Is this the Windows issue or it shows only error in Python 3.6 version? for you kind information I am using Python 3.6 in Windows platform.

在Opencv3中,不推荐使用cv模块.因此,在第11行中,您可以像下面这样初始化字体:

in Opencv3 the cv module is deprecated. So, in line 11 you can initialize the font like following:

font = cv2.FONT_HERSHEY_SIMPLEX