Closed uriva closed 6 years ago
I can't believe how many people here are recommending to edit the clumsy vscode setting
"python.linting.pylintArgs"
.Not only is it just solving the issue locally, especially when you edit your global vscode
settings.json
, it also overrides any settings from a.pylintrc
file, which is not immediately obvious. Using vscode's settings to add command line arguments to some binary running in the background is a bad idea in general, and should only be done as a last resort.What you should really do, in my opinion, is to generate a pylint configuration file inside your project folder like this:
pylint --generate-rcfile > .pylintrc
and then edit the settings
extension-pkg-allow-list
andgenerated-members
there.You can of course also edit these settings in your user- or system-wide .pylintrc, I'd advise against that though.
This. By far the most elegant solution. Thanks!
VS2019 works for me.
install opencv_headless and it works for me.
For pyproject.toml
file, add the following
[tool.pylint.typecheck]
generated-members = "cv2.*"
Note that using genrated-members
should be the last solution if nothing else work, because it will disable pylint's check on everything coming from cv2.
pip installation is wrong.
Easiest solution and you do not need to worry about any settings or incorrect changes. Much safer.
pip install opencv-python-headless
Try installing opencv-python-headless python dependency instead of opencv-python. That includes a precompiled binary wheel with no external dependencies (other than numpy), and is intended for headless environments like Docker. This saved almost 700mb in my docker image compared with using the python3-opencv Debian package (with all its dependencies).
The package documentation discusses this and the related (more expansive) opencv-contrib-python-headless pypi package.
Update 2023:
"pylint.args": ["--extension-pkg-whitelist=cv2"]
Hello There,
since the new release of OpenCV this no longer works. It still throws the no member error, regardless if you put in "--extension-pkg-whitelist=cv2" or --extension-pkg-allow-list=cv2 (as suggested in the official documentation, as "whitelist"seems dprecated). Any suggestion how to make that work?
Generating all members defies the purpose of PyLint in my opinion...
Could you open a new issue with a reproducer please @LambdaScorpii ? (Edit: Sorry Bad ping my Bad)
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