Skip to content

Instantly share code, notes, and snippets.

@umardx
Last active September 23, 2018 11:54
Show Gist options
  • Save umardx/e20a2f88064fda04ac26e21c71b600d2 to your computer and use it in GitHub Desktop.
Save umardx/e20a2f88064fda04ac26e21c71b600d2 to your computer and use it in GitHub Desktop.

First, find out where pipenv has created your virtualenv setup and stashed the python executable you are using. From the command line in your project folder (where your Pipfile is), execute the following:

pipenv --py

This will give you the full path to your virtualenv python install. For my sample project it was:

VIRTUALENV_PYTHON_PATH_HERE=C:\Users\UmarDx\.virtualenvs\api-9dSW7b5h\Scripts\python.exe

Now, create a local settings file that VS Code will use for your project

mkdir .vscode && touch .vscode/settings.json

Open the settings.json file and paste in the following:

{
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/*.pyc": true,
        "**/__pycache__": true
    },
    "python.pythonPath": "C:\\Users\\UmarDx\\.virtualenvs\\flask-login-96KNOJMU\\Scripts\\python.exe",
    "python.linting.pylintArgs": [
        "--load-plugins",
        "pylint_flask"
    ]
}

If you also have pylint installed in your virtualenv environment then it will use that version to display any linting problems. If not, you can do that with the following.

pipenv install --dev pylint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment