Search code examples
pythondirectoryvisual-studio-codepylint

Configuring Python in Visual Studio Code on Windows 10


I was working with Visual Studio Code and Python 3.7 installed in the default installation directory (\users\user\appdata\roaming), but when I updated my Python installation to the last version, "3.9.1", and after deleting all previous versions, I decided to install it in another directory (C:\Python), my Visual Studio Code does recognize my Python installation as you can see below:

Python in Visual Studio Code

But when running Visual Studio Code again, it tells me that Pylint isn't installed, logical since I deleted everything from the previous installation.

Pylint

The problem I'm facing right now is that when I install "pylint" it keeps installing in the default Python directory (\users\user\appdata\roaming) and telling me to add it to the "environment variables".

Pylint installation directory

How can I configure Visual Studio Code to install all libraries/modules in my new Python directory (C:\Python)?


Solution

  • An environment variable tells your system where the python.exe file is located. Pylint doesn't know where python.exe is. Use these steps:

    1. Right-clicking This PC and going to Properties
    2. Clicking on the Advanced system settings in the menu on the left
    3. Clicking on the Environment Variables button on the bottom right
    4. In the System variables section, select the Path variable and click on Edit. The next screen will show all the directories that are currently a part of the PATH variable
    5. Clicking on New and entering Python’s install directory