Visual Studio Code and Python on Windows

13 Jun 2019 - Sk1f3r

Share on:

The shortest way to get a complete pack of VSCode and Python on Windows PC.

1.Preparing Git

2.Preparing pyenv

git clone %USERPROFILE%/.pyenv

3.Modify PATH env

4.Installing Python

pyenv install 3.7.3-amd64

5.Installing poetry (project management), flake8 (code-style) and yapf (auto-formatting)

pyenv global 3.7.3-amd64
python -m pip install poetry flake8 yapf

6.Installing VS Code

7.Adding Python support

8.Configuring VS Code global settings

    "files.encoding": "utf8",
    "editor.rulers": [79],
    "python.linting.enabled": true,
    "python.linting.pep8Enabled": false,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.flake8CategorySeverity.E": "Warning",
    "python.linting.flake8CategorySeverity.F": "Warning",
    "python.linting.flake8CategorySeverity.W": "Warning",
    "python.linting.flake8Args": ["--exclude .venv"],
    "python.linting.ignorePatterns": [
    "python.formatting.provider": "yapf",

Now flake8 will automatically shows if any line of code has style mistakes and by pressing Shift+Alt+F it will be solved as possible.

9.Configuring VS Code keyboard shortcuts

                "key": "alt+q",
                "command": "python.execInTerminal",
                "key": "alt+w",
                "command": "python.createTerminal"

Now you can open python file from the project and:

• Press Alt+Q to execute a file in a terminal;

• Press Alt+W to create a terminal and activate virtualenv.

10.Creating a project

cd C:/dev/
poetry new project1

11.Creating venv

cd C:/dev/project1
pyenv local 3.7.3-amd64
python -m venv .venv

12.Opening a project

13.Adding packages in VS Code

14.Ready to code!

Tags: python windows git