python - 为什么 Pylint 告诉我 'module cv2 has no member' ?

标签 python opencv pylint cv2

我不断收到 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"],
}

相关问题:how-do-i-get-pylint-to-recognize-numpy-member

关于python - 为什么 Pylint 告诉我 'module cv2 has no member' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52668690/

相关文章:

python - 如何禁用特定文件的 pylint 错误消息?

python - Flask 和 sqlalchemy : Get uploaded file using path stored on database

python - PyTorch - 如何在评估模式下停用 dropout

opencv - 在给定R和T的情况下,立体整流能否始终成功

c++ - MLP : Relation between number of iteration and accuracy

python - Pylint 使用 git-pylint-commit-hook 忽略文件

python - 在Python中绘制numpy数组的值

python Pandas : pivot rows to columns based on duplicate index columns

c# - 无法在C#中获得正确的位图1290 x 960图像?

python - 如何将 Pylint 与 Geany 集成,以便我可以将 Geany 用作 python IDE?