question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pylint extension-pkg-whitelist=cv2 not working only when through the extension (Anaconda)

See original GitHub issue

Environment data

  • VS Code version: 1.42.1
  • Extension version (available under the Extensions sidebar): 2020.2.64397
  • OS and version: Win 10 64 bit Home
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.6 64-bit Anaconda
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions:
pylint 2.4.4
astroid 2.3.3
Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
  • Relevant/affected Python-related VS Code extensions and their versions: Code Runner 0.9.16
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): Jedi
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

If I set argument "python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"], the linter should look up members in the cv2 module.

Actual behaviour

image

Steps to reproduce:

  1. Open a script that imports cv2 in VSCode.

Logs

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

> ~\Anaconda3\envs\cv\python.exe -m pylint --extension-pkg-whitelist=cv2 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text s:\shared\new_scripts\cvprocess.py
cwd: s:\shared\new_scripts
##########Linting Output - pylint##########
************* Module cvprocess
...
61,8,convention,invalid-name:Variable name "nh" doesn't conform to snake_case naming style
67,12,error,no-member:Module 'cv2' has no 'imread' member
68,22,error,no-member:Module 'cv2' has no 'threshold' member
68,35,error,no-member:Module 'cv2' has no 'imread' member
68,66,error,no-member:Module 'cv2' has no 'THRESH_BINARY' member
69,18,error,no-member:Module 'cv2' has no 'Canny' member
71,12,error,no-member:Module 'cv2' has no 'HoughLinesP' member
25,27,warning,unused-argument:Unused argument 'time'
...
-------------------------------------------------------------------

Your code has been rated at -5.48/10 (previous run: 2.86/10, -8.33)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

(cv) S:\shared\new_scripts>%userprofile%\Anaconda3\envs\cv\python.exe -m pylint --extension-pkg-whitelist=cv2 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text s:\shared\new_scripts\cvprocess.py
************* Module cvprocess
...
61,8,convention,invalid-name:Variable name "nh" doesn't conform to snake_case naming style
25,27,warning,unused-argument:Unused argument 'time'
...
-------------------------------------------------------------------
Your code has been rated at 2.86/10 (previous run: -5.48/10, +8.33)

This was originally posted as a pylint issue but they diverted me here. It is really weird that running the same exe (I hope) with the same arguments results in different outputs. My terminal is set to Anaconda Prompt in the workspace.

Similar issues I found: #99, #606, #1648, #1993, #2879, #3562, #3802, #5257

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
747commented, Mar 18, 2020

Thank you for all your time and support, otherwise I’d not ever realize that problem. I’m going to support those issues.

0reactions
kimadelinecommented, Mar 17, 2020

Hurray it worked 🥳

Yes, you should be launching VS Code from the Anaconda prompt. On our side we should make it more explicit in the docs (https://github.com/microsoft/vscode-docs/issues/3481), and we will work towards telling users directly while in the extension as well (https://github.com/microsoft/vscode-python/issues/10626). You are more than welcome to upvote these 2 issues to bump up their visibility and priority.

Using conda run to run tools in the extension would most likely solve the pylint issue you reported originally, however it isn’t stable enough yet for us to use it (https://github.com/microsoft/vscode-python/issues/9490).

Closing in favour of https://github.com/microsoft/vscode-docs/issues/3481 and https://github.com/microsoft/vscode-python/issues/10626.

Thank you for your patience!

Read more comments on GitHub >

github_iconTop Results From Across the Web

PyLint not recognizing cv2 members - opencv - Stack Overflow
A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python ......
Read more >
Using Jupyter Notebook extensions - Anaconda Documentation
You can open Jupyter Notebook by running jupyter notebook , or by opening Anaconda Navigator and clicking the Jupyter Notebook icon. Obtaining the...
Read more >
Pylint - PyPI
Pylint is a static code analyser for Python 2 or 3. The latest version supports Python 3.7.2 and above. Pylint analyses your code...
Read more >
Messages control - Pylint 2.16.0-dev documentation
In order to control messages, pylint accepts the following values: a symbolic message: no-member , undefined-variable etc. a numerical ID ...
Read more >
Code Analysis - Spyder 4
The Code Analysis pane detects style issues, bad practices, potential bugs, ... Spyder Pylint pane, showing numerous issues discovered in a file ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found