用的python3.9,anaconda3,opencv4.6.0.66版本,opencv-contrib-python和opencv都安装成功,代码可以跑但是报错
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
img = cv.imread("1.jpg")
print(img)
cv.imshow("img", img)
cv.waitKey(10000)
cv.destroyAllwindows()
print(img.shape)
在 'init.py' 中找不到引用 'imread'
在 'init.py' 中找不到引用 'imshow'
在 'init.py' 中找不到引用 'waitKey'
在 'init.py' 中找不到引用 'destroyAllwindows'
运行结果
AttributeError: module 'cv2' has no attribute 'destroyAllwindows'
有反复重新安装过但是没有用
不报错
W要大写,是destroyAllWindows,不是destroyAllwindows
可以查看手册:python- 接下来? 中的内容