Skip to content

cv2 (opencv-python) intellisense not working #1993

Description

From Sergio Pedri (@Sergio0694) on June 17, 2018 21:17

Hello, I'm opening a new issue as I saw the previous ones have been closed already and I couldn't post there. It looks like the cv2 intellisense suggestions don't work, and VSCode currently marks as errors all the calls to any method/member of the cv2 module. Here's a screen:

image

  • VSCode Version: 1.24.1 x64
  • OS Version: Windows 10 Pro 17134.112 x64

Steps to Reproduce:

  1. Install the cv2 package with pip3 install --upgrade opencv-python
  2. Open VSCode, create a python file, add import cv2 and try to use any method from that package

Does this issue occur when all extensions are disabled?: No, as I don't get any kind of suggestions this way, and pylint seems to be disabled entirely with this option.

Thanks!

Copied from original issue: microsoft/vscode#52139

Activity

  1. brettcannon commented on Jun 18, 2018

    @brettcannon
    Member

    Sergio Pedri (@Sergio0694) IntelliSense works for me for cv2. Based on the fact that PyLint is saying it can't find cv2 I suspect that your pip3 command is not installing into the same Python environment you have selected for VS Code. If you're using a virtual or conda environment then use Python: Create Terminal and install cv2 either using conda or python -m pip install --upgrade opencv-python.

  2. Sergio0694 commented on Jun 18, 2018

    @Sergio0694
    Member

    Brett Cannon (@brettcannon) Hello, thank you for you reply. I've followed your advice, uninstalled the package from pip3 and installed it again using python -m pip install --upgrade opencv-python.

    Now it looks like VSCode does show the suggestions in the dropdown menu, but for some reason at the same time it also says it can't find any method inside the package. Here's a screen:

    image

    This is the error I'm getting in that screen:

    [pylint] E1101:Module 'cv2' has no 'cvtColor' member

    Is there something else I need to configure on my end? I'm not sure as to why it's correctly showing the methods from the suggestions box, while also marking them as errors in the line just above.
    Thanks again!

  3. DonJayamanne commented on Jun 19, 2018

    @DonJayamanne

    [pylint] E1101:Module 'cv2' has no 'cvtColor' member

    Please ensure the packages pylint and opencv-python are installed in the same Python environment, the one used by VS Code extension. You can check what interpreter is used by VS Code by looking at the bottom left of the status bar.

    Note: If the problem persists, try running the linter from the command prompt manually, e.g. pylint <filename.py>. If you get the same error reported, then please report this issue upstream in pylint.

  4. locked as resolved and limited conversation to collaborators on Jul 17, 2018
  5. brettcannon commented on Nov 20, 2018

    @brettcannon
    Member

    Solution as described in pylint-dev/pylint#2426

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions