pylint extension-pkg-whitelist=cv2 not working only when through the extension (Anaconda)
See original GitHub issueEnvironment 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
Steps to reproduce:
- Open a script that imports
cv2
in VSCode.
Logs
Output for Python
in the Output
panel (View
→Output
, 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:
- Created 4 years ago
- Comments:15 (1 by maintainers)
Top GitHub Comments
Thank you for all your time and support, otherwise I’d not ever realize that problem. I’m going to support those issues.
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!