“linter pylint is not installed” in VSCode

VSCode is a lightweight, open source, cross-platform code editor. It has strong built-in support for many different tools in various programming languages.

It is both a blessing and a curse. On one hand, people can quickly take advantages of their existing tooling and workflow without leaving VSCode. But on the other hand, you would have to learn how to configure all of them inside the text editor.

In this article, we are going to show you how to fix "Linter pylint is not installed" message that pops up every time you open a .py file in VSCode.

Pylint is actually not installed

The first thing you have to check is whether pylint is actually installed or not. Follow these steps to do that.

  1. Open VSCode integrated terminal by pressing Ctrl + ` key combination.

  2. Run "python --version" command to check which Python environment the VSCode terminal is currently in:

    enter image description here

    If the output from terminal and the version number displayed in the lower corner are not the same, that means you are having two different Python installation on your system.

    Uninstall one of them, or change pythonPath in settings.json to make sure that only one installation is used across VSCode components.

  3. Once the version numbers match, if the problem still persist, we can now use pip show pylint command to check where pylint is installed:

enter image description here

Explicitly specify Python binary path

Separate Python 2 and 3 installation combined with pip/pip3 difference are two of the most confusing thing for beginners who are getting started with the language. The problem mostly happens in Linux.

You need to make sure pylint is installed in the same environment that VSCode detects. This may be the problem!

Open up a terminal and run pip --version, it will tell you the current version of pip and python associated with pip.

~$ pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Re-check the pip version number associated with whatever python version you are going to use, in my case, it's python3.

~$ python3 -m pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

As you can see, they match up, so I'm going to find out the binary path of python3 by running which python3.

~$ which python3
/usr/bin/python3

Now that we knew where is the Python (already associated with pip ) that we want to use, we need to explicitly specify it in VSCode settings.

With VSCode open, fire up Command Palette and search for Settings (JSON). In thesettings.json file, look for the python.pythonPath key. It may look something like this :

"python.pythonPath": "/usr/bin/python3"

If that doesn't work: consider running pip from a virtual environment. I personally used it universally across my work and play machines without any issues for the past few years.

"python.linting.pylintEnabled": false

Pylint vs Pylint3 (Linux specific)

If you've installed pylint through a package manager, it may have been registered with the system under the alias pylint3 instead of the default pylint.

In this case, you need to edit your settings.json to explicitly specify python.linting.pylintPath, as reports from VSCode repo suggest.

"python.linting.pylintPath": "pylint"
NEEDS TO BE CHANGED TO
"python.linting.pylintPath": "pylint3"

Check permissions of pylint path

![linux permissions](https://raw.githubusercontent.com/linuxpip/imghost/master/1622043840250-linux permissions.png)

When you were present with pylint not installed message, it often comes with a Install pylint button which allows you to quickly run

pip install pylint

Now if you're running VSCode in administrator mode, it would run the command with admin rights.

This could changed the owner of .local/lib/ to root and made it inaccessible to VScode.

In order to verify that the permissions are right, run ls -ld ~/.local/lib/ command in the terminal . If the output looks like below, you need to chown it back to yours.

drwx------ 3 root root 4096 Sep 24 10:49 /home/your_userName/.local/lib/

Runing chown with your group and your username should fix the issue.

sudo chown -R your_group:your_user ~/.local

Now the output of ls -ld ~/.local/lib/ should become

drwx------ 3 your_group your_user 4096 Sep 24 10:49 /home/linuxpip/.local/lib/

Explicitly specify Python Language Server

pylance-Python Language Server

In order to provide advanced editing features for various programming languages such as autocomplete, error checking, jump-to definition, etc, VSCode used language servers internally.

In the case of Python, through the years, the default VSCode language server for it has switched from Jedi to Microsoft Python Language Server and now Pylance.

While language servers doesn't pose any problem in normal situation, it could be the source of conflicts with specific setups.

For example, Microsoft Python Language Server and pylint seems to be a problematic combination in vscode-python extension. According to this, Microsoft Python Language Server doesn't run Pylint, so it's an integration issue in the extension.

So, fixing "pylint is not installed" can be as easy as updating VSCode to the latest version to make use of the new Pylance language server, or inspect settings.json and delete all keys related to python.languageServer.

You can also explicitly specify the language server for Python in VSCode by adding "python.languageServer": "Pylance" into settings.json.

Reinstall python/pip on Windows with chocolatey

chocolatey-install-python

Windows use a packaged install system, which makes it hard for related programs to communicate with each other, as they have no way to find where the other programs are located at. The problem becomes worse with folder permissions, administrator execution rights and system variables.

chocolatey is a simple, pragmatic, and open approach to software management on Windows. It works similar to the way package managers in Linux operate. Each program has its own installation script, which does the installation itself along with configuration.

First, uninstall existing Python installation from your system. Suppose you got chocolatey installed, simply enter these two commands into an elevated Command Prompt to have Python 3 and pip installed (according to The Hitchhiker's Guide to Python).

choco install python
python -m pip install -U pip

Pylint in WSL

If you're a Windows user looking for a way to use pylint which was installed inside WSL subsystem, there's a solution.

In May 2019, Microsoft released Remote-WSL as a part of Remote Development extension pack, promise to let you use VSCode on Windows to build Linux application that runs on WSL subsystem. You can keep your refined workflow along with all the tooling and utilities without leaving Windows.

Visual Studio Code Remote - WS

How to use Remote Development on VSCode is outside of this article scope, but Microsoft has written a couple of posts that may worth your time.

Use another linter

python/mypy - Optional static typing for Python 3 and 2

While being the default linter for Python, pylint is not the only linter supported in VSCode. Here's a list of all linters that VSCode supports.

  • pylint
  • flake8
  • mypy
  • pydocstyle
  • pycodestyle
  • prospector
  • pylama
  • bandit

If you have tried all the methods mentioned above and nothing works, you may consider replace pylint with flake8 or mypy, as they are mature linters with complete sets of features.

In order to select a different linter, fire up VSCode Command Palette and select the Python: Select Linter command.

You can also edit your settings (in JSON mode) manually to enable multiple linters. Visit VSCode Python Linting guide for detailed information.

Click to rate this post!
[Total: 27 Average: 5]

Leave a Comment