I want to run Python code in Microsoft Visual Studio Code but it gives an error:
Linter pylint is not installed
I installed:
- The Visual Studio Code Python extension
- Python 3
- Anaconda
How can I install Pylint?
I want to run Python code in Microsoft Visual Studio Code but it gives an error:
Linter pylint is not installed
I installed:
How can I install Pylint?
Check the path Pylint has been installed to, by typing which pylint
on your terminal.
You will get something like: /usr/local/bin/pylint
Copy it.
Go to your Visual Studio Code settings in the preferences
tab and find the line that goes
"python.linting.pylintPath": "pylint"
Edit the line to be
"python.linting.pylintPath": "/usr/local/bin/pylint"
,
replacing the value "pylint"
with the path you got from typing which pylint
.
Save your changes and reload Visual Studio Code.
ctrl+~
)pip install pylint
If that doesn't work: On the off chance you've configured a non-default Python path for your editor, you'll need to match that Python's install location with the pip executable you're calling from the terminal.
This is an issue because the Python extension's settings enable Pylint by default. If you'd rather turn off linting, you can instead change this setting from true
to false
in your user or workspace settings:
"python.linting.pylintEnabled": false
If you're working in a virtual environment (virtualenv), you'll definitely need to update the python.lintint.pylintPath
setting (and probably the python.pythonPath
setting, as well, if you haven't already) if you want linting to work, like this:
// File "settings.json" (workspace-specific one is probably best)
{
// ...
"python.linting.pylintPath": "C:/myproject/venv/Scripts/pylint.exe",
"python.pythonPath": "C:/myproject/venv/Scripts/python.exe",
// ...
}
That's for Windows, but other OSs are similar. The .exe
extension was necessary for it to work for me on Windows, even though it's not required when actually running it in the console.
If you just want to disable it, then use the python.linting.pylintEnabled": false
setting as mentioned in Ben Delaney's answer.
This solved the issue for me:
pip install pylint -U
I.e., upgrade the pylint
package.
Try doing this if you're running Visual Studio Code on a Windows machine and getting this error (I'm using Windows 10).
Go to the settings and change the Python path to the location of YOUR python installation.
I.e.,
Change: "python.pythonPath": "python"
To: "python.pythonPath": "C:\\Python36\\python.exe"
And then: Save and reload Visual Studio Code.
Now when you get the prompt telling you that "Linter pylint is not installed", just select the option to 'install pylint'.
Since you've now provided the correct path to your Python installation, the Pylint installation will be successfully completed in the Windows PowerShell Terminal.
If you're reading this in (or after) 2020 and are still having issues with Pylint in Visual Studio 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 Visual Studio 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 Visual Studio Code
That got rid of the warnings for me, and successfully enabled pylinting.
I also had this problem. If you also have Visual Studio installed with the Python extension, the system will want to use Studio's version of Python. Set the Environment Path to the version in Studio's Shared folder. For me, that was:
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\
After that, run
python -m pip install pylint
from a command prompt with Administrator rights.
If you are using MacPorts, you may need to activate package pylint and autopep8 after you've installed them, i.e.:
sudo port select pylint pylint36
sudo port select autopep8 autopep8-36
I had this issue as well and found the error's log regarding permissions or something.
So, I ran Visual Studio Code with administrator privileges and ran "pip install pylint" in the terminal. Then the error seemed to be fixed.
(I run Visual Studio Code on Windows 10.)
If you're using pipenv then you just have to
pipenv install pylint
to install Pylint to your virtual environment
pipenv shell
to activate the environment and thus make Pylint available. Then start code
in that environment
code .
Boom! you're good to code ;-)
The following fix works for me. In a Ubuntu 16.04 (Xenial Xerus) terminal, type:
$ pip3 install pylint
$ sudo apt install python3-pip
If your Python 3 is installed in the /usr/bin/python3.6 folder, run the following command, and it should work fine. Last, make sure your Visual Studio Code is running the Python 3 interpreter, not Python 2.7 which is default in Ubuntu.
$ /usr/bin/python3.6 -m pip install -U pylint
A similar issue happened to me after I a completely reinstalled Python. Opening the settings.json
by Ctrl+ ⇧ Shift+P:
and I saw that I had set the default linter to
"python.linting.pylintPath": "pylint_django"
so opening a terminal (e.g., Ctrl + ⇧Shift + ~) and the installing
pip install pylint_django
solved the problem.
I had this issue this weekend. It seems to have happened because I opened my project in my venv, but I 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 Visual Studio Code 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.
I would like to add my trials and my solution following rob3c's answer.
PS: My solution only concerns Windows users.
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 the Python 3 interpreter C:\Python34\python.exe
)
And to configure .vscode\settings.json as follows:
// 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
✓ Visual Studio Code uses the Pylint version from my toolchain!