Solvedpylint cv2 module members are not recognized

When importing cv2 I get errors such as:

[pylint] E1101:Module 'cv2' has no 'imread' member
[pylint] E1101:Module 'cv2' has no 'resize' member
[pylint] E1101:Module 'cv2' has no 'imshow' member
[pylint] E1101:Module 'cv2' has no 'waitKey' member
[pylint] E1101:Module 'cv2' has no 'destroyAllWindows' member

etc'

(the code itself runs fine)

I'm using VSCode 1.26.1 and Python 3.6.5.

See this issue for more complaints: https://github.com/DonJayamanne/pythonVSCode/issues/623

51 Answers

✔️Accepted Answer

  1. On VScode: CTRL + Shift + P
  2. Choose "Preferences: Open Settings (JSON)"
  3. Add this line into JSON file:
    "python.linting.pylintArgs": ["--generate-members"]
  4. Done, it works for me 👍

Other Answers:

To future readers, in vsc this means adding this line to the settings:
"python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"]

https://www.bilibili.com/video/av33693850/
"python.linting.pylintArgs": ["--generate-members"]

The "python.linting.pylintArgs": ["--generate-members"] is wrong, it will make pylint not work.
The correct way is to set ""python.linting.pylintArgs": ["--generated-members=cv2.*"] which only config for cv2, reference @bjtho08 reply in #779.

  1. On VScode: CTRL + Shift + P
  2. Choose "Preferences: Open Settings (JSON)"
  3. Add this line into JSON file:
    "python.linting.pylintArgs": ["--generate-members"]
  4. Done, it works for me 👍

Thanks, man! it worked for me too

More Issues: