我不断收到 pylint 错误提示:
module 'cv2' has no "something" member
我的 cv2 模块不工作。
我不知道为什么;据我所知我安装正确。我什至卸载并重新安装了大约 20 次。
当我打印出我的 python 库中的模块时,cv2 被打印出来;它的功能被正确打印。我使用的是 python 3.6.6,没有安装其他版本的 python。
例如,此代码将打印:“图像相同” 无论我给它什么图片,因为 2 张图片总是等于“无”。
import cv2
import numpy as np
image1 = cv2.imread("1.jpg")
image2 = cv2.imread("2.jpg")
difference = cv2.subtract(image1, image2)
result = not np.any(difference) #if difference is all zeros it will return False
if result is True:
print ("The images are the same")
else:
cv2.imwrite("result.jpg", difference)
print ("the images are different")
有人知道这是怎么回事吗?
最佳答案
如果您不想添加更多配置,请将此代码添加到您的配置文件中,而不是“白名单”。
{
"python.linting.pylintArgs": ["--generate-members"],
}
关于python - 为什么 Pylint 告诉我 'module cv2 has no member' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52668690/