pythonvisual-studio-code

pythonVSCode, venv and pylint


I am trying to get pythonVSCode working with a venv virtual environment for Python 3.6 on a Mac.

Following the documentation, I activated the virtual environment and launched Visual Studio Code from the terminal.

When Visual Studio Code suggested installing Pylint, I tried using the pythonVSCode's "Install" button that came with the suggestion, but that threw an error in Visual Studio Code's terminal:

/usr/bin/python -m pip install pylint
$ /usr/bin/python -m pip install pylint
/usr/bin/python: No module named pip

I then installed Pylint via the system (not Visual Studio Code's) terminal and within the virtual environment:

(venv) $ pip install pylint

... and re-launched Visual Studio Code from the terminal.

Visual Studio Code still suggests installing Pylint.

I suspect this has something to do with paths. I expected launching Visual Studio Code from within the virtual environment will load that environment's interpreter, including Pylint, in Visual Studio Code, but it seems not to be the case.


Solution

  • I had the same problem as of 2018-07.

    Solution: activate your virtualenv:

    source yourenv/bin/activate
    

    In the terminal with the active virtualenv, do the following:

    Install Pylint in your virtualenv:

    pip install pylint
    

    Open Visual Studio Code from the terminal, inside your virtualenv, using the "code" command. Let open only the new Visual Studio Code instance.

    code
    

    Have fun coding using Pylint.