Python AttributeError: 模块 'cv2.cv2' 没有属性 'cv'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44640911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AttributeError: module 'cv2.cv2' has no attribute 'cv'
提问by Manjurul Ahsan
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:
我想我在 windows 系统或 python 3.6 版本上有一些问题。我正面临一些属性错误。我已经检查并仔细检查了我的代码,没有错误,我还将我的代码与其他代码进行了比较,我发现没有错误。那为什么我会面临这种错误。我在这里添加我的代码:
and i am facing following error.
我正面临以下错误。
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'
Process finished with exit code 1
C:\Users\MAN\AppData\Local\Programs\Python\Python36\python.exe C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognizerr.py Traceback(最近一次调用):文件“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'没有属性“cv”
进程以退出代码 1 结束
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.
这是 Windows 问题还是仅在 Python 3.6 版本中显示错误?对于您的信息,我在 Windows 平台上使用 Python 3.6。
回答by Nuhil Mehdy
in Opencv3 the cv
module is deprecated. So, in line 11 you can initialize the font like following:
在 Opencv3 中,该cv
模块已弃用。所以,在第 11 行,你可以像下面这样初始化字体:
font = cv2.FONT_HERSHEY_SIMPLEX