-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
cv2 module members are not recognized #2426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This should work if you pass |
To future readers, in vsc this means adding this line to the settings: |
Thanks @PCManticore However, even with the extension enables, pylint still doesn't recognise 2nd level members, such as I believe it is the same case as #779 ? |
@ashraf-minhaj use the Cmd+shift+p shortcut (or ctrl instead of cmd) and type "open settings (json)". There should be an option which opens the json settings and you can add the line there |
I'm encountering the same situation:
|
As mentioned, most of the errors should be already solved by using |
https://www.bilibili.com/video/av33693850/ |
For me, pylint cannot process cv2 when I build cv2 from source. Works when installed using pip. |
@mehanton this works for me. Thank you. :) |
|
Thanks, man! it worked for me too |
on VSCode Ubuntu I did |
Hm.... I can't edit "defaultSetting.json file.... |
@insung3511 It must be "settings.json", not "defaultSetting.json"! Make sure you choose "Preferences: Open Settings (JSON)", not "Preferences: Open Default Settings (JSON)" 👌 |
thanks |
thanks for the help guys |
The "--generate-members" option is wrong! |
Look at this, but the solution mentioned here won't work either. |
The |
i compiled opencv from soruce and passed the args to pylitn but still intellisense doesnt work, there is another way to solve? |
I also facing the same problem of "cv2 module members are not recognized |
Now my pylint just don't show any erros 😅 |
Thanks that solves it.
|
Thanks
… On 07-Aug-2020, at 10:51 AM, Shivam Mukherjee ***@***.***> wrote:
@Shinit5201 <https://github.com/Shinit5201>
<https://user-images.githubusercontent.com/12777564/89611882-ea42d380-d89b-11ea-959c-92d43a821240.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2426 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/APVLRH3TAOJMCQRBJZ5VC33R7OFN3ANCNFSM4FQPTXBA>.
|
After reading such complex tasks, I was totally surprised. A very simple way is: It works like a charm. |
You could also take a step further and import even more granularly into individual classes or features instead of the whole module! |
It worked dude!!😁 |
For cv2 reference: pylint-dev/pylint#2426 Signed-off-by: Ashish Saini <sainiashish08@gmail.com>
a simple solution wow thank you |
Btw, tts 2020-09-28 already, why people still have to setup this stuff for pylint? |
That argument is wrong and will make pylint fail silently. See the comments earlier in the thread for an explanation. |
It won't report an error in VS Code's problems tab any longer that's true. But if you run pylint from your terminal you'll still get
with E1101: Module 'cv2' has no 'imread' member (no-member) with |
Worked for me too. Thanks |
Thanks! worked for me too |
I can't believe how many people here are recommending to edit the clumsy vscode setting Not only is it just solving the issue locally, especially when you edit your global vscode 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 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. |
I read [1], [2] and then tried this... [1] pylint-dev/pylint#3437 [2] pylint-dev/pylint#2426 Interesting [3] seems to recommend what we used to do `from cv2 import cv2` or somesuch... [3] pylint-dev/pylint#2426 (comment)
install opencv_headless and it works for me. |
For [tool.pylint.typecheck]
generated-members = "cv2.*" |
Note that using |
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) |
Option 1Add pylint --generated-members=cv2.* client.py Option 2Run:
Then open
|
hi @SajjadAemmi, Thanks for the advice. Unfortubnately, this won't work well because, a) you annot configure this in a persistent manner in the pylint extenstion and b) this removes every scope on linting when it starts with cv2 regardless if right or wrong, so kind of defies the point of the whole linting. |
this work for me in 2025, in settings search |
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
The text was updated successfully, but these errors were encountered: