Skip to content

import cv2 not detected #2879

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

Closed
kelvinwop opened this issue Oct 13, 2018 · 5 comments
Closed

import cv2 not detected #2879

kelvinwop opened this issue Oct 13, 2018 · 5 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@kelvinwop
Copy link

kelvinwop commented Oct 13, 2018

Environment data

  • VS Code version: 1.27.2
  • Extension version (available under the Extensions sidebar): 2018.9.0
  • OS and version: Win 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): n/a
  • Relevant/affected Python packages and their versions: idk

Actual behavior

Module 'cv2' has no [basically everything] member. (Runs perfectly when executed)

Expected behavior

No error.

Steps to reproduce:

  1. import cv2 and use a method

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

n/a

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

n/a

Additional Comments:
The error is basically because:

cv2\__init__.py:

import importlib

from .cv2 import *
from .data import *

# wildcard import above does not import "private" variables like __version__
# this makes them available
globals().update(importlib.import_module('cv2.cv2').__dict__)

cv2 imports stuff weird. No clue how you can detect that kind of stuff. Good luck lol

@kelvinwop
Copy link
Author

opencv/opencv-python#131

They claim it's a pylint issue as well

@brettcannon
Copy link
Member

I don't quite understand what the problem is. Are you not getting Intellisense? Or you getting a strange message from Pylint?

@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster labels Oct 15, 2018
@Flamefire
Copy link

There are already multiple issues on this, e.g. #1993

As this question comes up quite often even on SO (https://stackoverflow.com/questions/52668690/why-is-pylint-telling-me-module-cv2-has-no-member, https://stackoverflow.com/questions/50612169/pylint-not-recognizing-cv2-members) the correct answer should be provided here and in #1993 as it comes up in Google when looking for it (@DonJayamanne could you add it there too?)

Solution as described in pylint-dev/pylint#2426:

Add --extension-pkg-whitelist=cv2 to pylints arguments e.g. via "python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"]

@brettcannon brettcannon added triage and removed bug Issue identified by VS Code Team member as probable bug labels Nov 20, 2018
@brettcannon brettcannon self-assigned this Nov 20, 2018
@brettcannon
Copy link
Member

@Flamefire thanks! I copied the details over.

@brettcannon
Copy link
Member

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants