I want to run python code in Microsoft Visual Studio Code but it gives an error:
\"Linter pylint is not installed\"
I installed:
If you're reading this in (or after) 2020 and still having issues with pylint in VS Code for Windows 10, here is a quick solution that worked for me:
Make sure python is installed for Windows, and note the installation path
From an elevated command prompt, go to the installation directory for python
cd C:\Users\[username]\Programs\Python\Python[version]\
Install pylint
python -m pip install pylint
Pylint is now installed in the 'Python\Python[version]\Scripts\
' directory, note/copy the path for later.
Open settings in VS Code: Ctrl + ','
Type in python.defaultInterpreterPath
in the search field, and paste in the path to the Windows installation path for python:
(e.g. C:\Users\[username]\AppData\Local\Programs\Python\Python[version]\python.exe
)
Do the same for python.pythonPath
, using the same path as above
Lastly, search for python.linting.pylintpath
and paste the path to pylint.exe
Restart VS Code
That got rid of the warnings for me, and successfully enabled pylinting.
I would like to add my trials and my solution following rob3c's answer.
PS: My solution only concern Windows user.
I tried the following settings without success:
// settings.json
"python.linting.pylintPath": ${workspaceFolder}\\_tools\\python3\\Scripts\\pylint
and
"python.linting.pylintPath": ${workspaceFolder}\\_tools\\python3\\Scripts\\pylint.exe
I always had the following error message:
Linter 'pylint' is not installed. Please install it or select another linter".
Error: spawn c:\WS\myproject\_tools\python3\Scripts\pylint ENOENT
Even with a pylint file in my folder:
dir c:\WS\myproject\_tools\python3\Scripts\
...
05.07.2017 09:34 AM 52 pylint # ! no pylint.exe !
...
As my toolchain is based on msys
, the pylint installed is without pylint.exe.
The content of _tools\python3\Scripts\pylint
file:
#!python
from pylint import run_pylint
run_pylint()
My workaround was to create a batch file .vscode\pylint.bat with the following contents:
%PYTHON3_EXE% _prefix\python3\Scripts\pylint %*
(%PYTHON3_EXE% is an environment variable to python3 C:\Python34\python.exe
)
and to configure .vscode\settings.json as follow:
// settings.json
"python.linting.pylintPath": "${workspaceFolder}\\.vscode\\pylint.bat",
Log from OUTPUT
--> Python
:
##########Linting Output - pylint##########
c:\WS\myproject>C:\Python34\python.exe _tools\python3\Scripts\pylint
--rcfile c:\WS\framework\pylintrc
--msg-template='{line},{column},{category},{msg_id}:{msg}'
--reports=n
--output-format=text
c:\WS\myproject\myScriptToLint.py
Using config file c:\WS\myproject\pylintrc
------------------------------------
Your code has been rated at 10.00/10
✓ vscode uses the Pylint version from my toolchain!
I had this issue this weekend. It seems to have happened because I opened my project in my venv, but also opened a second instance outside of the venv. I never closed either instance - I just shut my PC down and let windows do the work. When I went back and called up VSCode from within my venv, both the project, and the other non-venv window opened. That's when I started seeing this error.
To fix it I had to remove the \.vscode
folder from the workspace directory.