VS Code – Fixing Pylint not installed in PipEnv environment error

VS Code has an annoying little error when using a PipEnv virtual environment were by it keeps prompting you to install pylint even though you have installed it. It is easily fixed though.

N.B – These instructions are written for windows users but you should be able to work out how to apply the same to Mac / Linux easy enough.

First make sure that you are using the correct Python interpreter for your virtual environment. You can see this in the bottom left corner and also click on the current environment as a shortcut to open up the list of available interpreters to choose from. Alternatively you can open up the command palette with Ctrl+Shift+P  look for Python: Choose Interpreter.

Once you are sure you are using the correct interpreter for your virtual environment open a terminal window in VS Code and then click on a python file to load it into the editor window. You should get the notice that pylint is not installed. If you have not already , then click to install.

Next you need to go to settings  (File > Preferences > Settings  or via the Command Palette if you prefer) and chose the tab that pertains to your virtual environment project folder settings. Open the settings.json file (click on the curly brackets near the top right corner to do this) and add the following to the file:

 

 "python.linting.pylintPath": "C:\\Users\\USERNAME\\.virtualenvs\\PROJECTNAME-7IDOZnzn\\Scripts\\pylint.exe", 

Your username, projectname and virtual environment name will be different of course, adjust as required. You can find out the path of your virtual environment by entering pipenv –venv in the terminal window.

Your settings file should have something like the  following entries (plus anything additional you may have)

{"python.pythonPath": "C:\\Users\\USERNAME\\.virtualenvs\\PROJECTNAME-7IDOZnzn\\Scripts\\python.exe","python.linting.pylintPath": "C:\\Users\\USERNAME\\.virtualenvs\\PROJECTNAME-7IDOZnzn\\Scripts\\pylint.exe","python.linting.pylintEnabled": true,"python.linting.enabled": true}

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.