Skip to content

import cv2 not detected #2879

Description

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 (View→Output, 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

Activity

  1. kelvinwop commented on Oct 14, 2018

    @kelvinwop
    Author

    opencv/opencv-python#131

    They claim it's a pylint issue as well

  2. brettcannon commented on Oct 15, 2018

    @brettcannon
    Member

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

  3. added
    bugIssue identified by VS Code Team member as probable bug
    info-neededIssue requires more information from poster
    on Oct 15, 2018
  4. Flamefire commented on Nov 20, 2018

    @Flamefire

    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 (Don Jayamanne (@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"]

  5. added and removed
    bugIssue identified by VS Code Team member as probable bug
    on Nov 20, 2018
  6. brettcannon commented on Nov 20, 2018

    @brettcannon
    Member

    Alexander Grund (@Flamefire) thanks! I copied the details over.

  7. brettcannon commented on Dec 13, 2018

    @brettcannon
    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.

  8. locked as resolved and limited conversation to collaborators on Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

info-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions