Visual Studio code and virtualenv

As 2018.03 there's an article how to add virtualenv to your python path list per particular workspace: https://code.visualstudio.com/docs/python/environments

All you have to do is File->Save workspace as.. and then add to the settings of workspace virtualenv:

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "python.pythonPath": "${workspaceFolder}/.venv/bin/python"
    }
}

You need to set up the path for your virtual environments in your workspace settings file: https://code.visualstudio.com/docs/python/environments

Save your workspace then open <workspace_name>.code-workspace file and add your virtual environment folder to the settings:

{
    "folders": [
        {
            "path": "<path-to-your-workspace>"
        }
    ],
    "settings": {
        "python.venvPath": "<path-to-your-virtual-env-folder>"
    }
}

After that open command palette (CMD/CTRL + SHIFT + P) and type select interpreter. Then choose the one from the desired virtual environment.


@mikebz you need to configure the path to the python executable as follows:
"pythonPath":"${workspaceRoot}/env/dev/bin/python"

The path may not be 100% accurate (please double check it), but that's how you need to configure it in launch.json.
With the next version of VS Code you will no longer have to do this, i.e. you won't have to configure this same setting in two files.

More details on configuring the path for debugging can be found here: https://github.com/DonJayamanne/pythonVSCode/wiki/Python-Path-and-Version#python-version-used-for-debugging