Solving 'Module ... has no member...' in VS Code


Short note on how to remove the error messages like Module 'cv2' has no '...' member on VS Code.

In VS Code, open the setting.json file by pressing ctrl+shift+p to open the Command Palette and type “settings” in the text field. You should see “Preferences: Open Settings (JSON)”.


Then open settings.json and add:

"python.linting.pylintArgs": ["--generated-members=cv2.*"],

With the libraries you’re using.
You can also use this argument when running pylint in the console:

pylint --generated-members=numpy.*

Or creating a pylintrc file:

pylint --generate-rcfile > .pylintrc

And then modifying the appropriate line:

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.

You can read the official documentation about this feature there.

comments powered by Disqus