Skip to content

cv2 (opencv-python) intellisense not working #1993

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
RMacfarlane opened this issue Jun 18, 2018 · 4 comments
Closed

cv2 (opencv-python) intellisense not working #1993

RMacfarlane opened this issue Jun 18, 2018 · 4 comments

Comments

@RMacfarlane
Copy link

From @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

@brettcannon
Copy link
Member

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

@Sergio0694
Copy link
Member

Sergio0694 commented Jun 18, 2018

@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!

@DonJayamanne
Copy link

DonJayamanne commented Jun 19, 2018

[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.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 17, 2018
@brettcannon
Copy link
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants