我点安装了OpenCV-python。安装似乎很好,我在python IDLE上对其进行了测试。它运行没有任何问题。我一直在尝试在VS Code上运行它,但似乎不起作用。自动完成功能可以识别imread函数,但是当我键入它时,会抛出一个错误,提示cv2没有imread成员。我正在使用最新版本的python
我这样称呼它:img2 = cv2.imread("C:\Biometric\min.jpg", 0)
答案 0 :(得分:3)
如果可以通过选择“在终端中运行Python文件”来运行代码,则可能是VS Code扩展中的错误。参见issue for details
我认为您可以从计算机上禁用/卸载扩展程序,也可以忽略它。
答案 1 :(得分:3)
由于您尝试使用VS Code执行此操作,请尝试执行以下步骤
(1) open palette on VS Code (use specifies command): CTRL + Shift + P
(2) then select "Preferences: Open Settings (JSON)" option in the palette dropdown
(3) then add the following line in the opened "settings.json" file
"python.linting.pylintArgs": ["--generate-members"]
这必须工作
答案 2 :(得分:2)
"python.linting.pylintArgs": ["--generated-members=cv2.*"]
答案 3 :(得分:1)
我尝试了很多黑客。他们没有工作。有人建议:
from cv2 import cv2
我认为这是解决此问题的最佳方法
答案 4 :(得分:1)
Ctrl + Shift + P->首选项:打开设置(JSON)
然后添加以下内容:
"python.linting.pylintArgs": ["--generate-members"]
为我工作。
答案 5 :(得分:0)
转到终端并输入newCellJobHost.appendChild(newJobHost);
对我有用。
答案 6 :(得分:-2)
尝试放置:
**from cv2 import cv2**
这肯定可以工作