Introduction
VS Code is the most popular Python editor for good reasons — but out of the box it's a fancy text editor. The difference between *using* VS Code and *living* in it is about fifteen minutes of setup: the right extension, the right interpreter, and a debugger you'll wonder how you lived without.
This guide walks through that setup once, properly, so every project afterward just works — especially the Streamlit apps you'll build from this site's tutorials.
Step 1: The One Essential Extension
Install Python (publisher: Microsoft) from the Extensions panel (Ctrl+Shift+X / Cmd+Shift+X). It brings IntelliSense (autocompletion), linting, debugging, and Jupyter support in one package.
Skip the temptation to install twenty extensions — the Python extension plus VS Code itself covers 95% of what you need. Add Pylance if it isn't bundled already (it's the language server that powers autocomplete quality).
Step 2: Select the Right Interpreter
This is the single most important setting. Open a project folder (File → Open Folder), then:
Ctrl+Shift+P (Cmd on Mac) → Python: Select Interpreter..venv (see the virtual environments guide).VS Code remembers per-project. Every symptom of "it runs in my terminal but VS Code shows import errors" traces back to this one selection — the editor is using a different Python than your terminal.
Step 3: Settings That Matter
Open Settings (Ctrl+,) or create .vscode/settings.json in your project:
{
"editor.formatOnSave": true,
"editor.rulers": [88],
"python.analysis.typeCheckingMode": "basic",
"files.exclude": {
"__pycache__": true,
".venv": true
}
}formatOnSave is the habit-former: install the Black Formatter extension, and every save produces consistently formatted code — zero mental effort spent on style, ever. The ruler at 88 marks Black's line length so long lines announce themselves.
Step 4: Debugging — The Superpower
Stop using print() for debugging. Set a red breakpoint by clicking left of a line number, press F5, choose Python File, and:
Watching a loop's variables change step by step answers questions print never can. This alone is worth the entire setup.
Step 5: The Daily Workflow
Ctrl+ ` opens a terminal *inside* your venv context; run scripts and Streamlit without leaving the editor.Ctrl+Shift+P runs every VS Code command; learn it and menus stop mattering.Ctrl+P jumps to any file by typing a fragment.Common Issues & Fixes
.venv.streamlit run app.py in the integrated terminal instead of the debugger..venv from analysis via python.analysis.exclude.Key Concepts
What to Try Next
# %% cells in a .py file run interactively.FAQ
VS Code or PyCharm?
VS Code is lighter, faster to start, and general-purpose; PyCharm is heavier with more Python-specific power out of the box. Both are excellent — VS Code's flexibility wins for most learners who also touch HTML/JS/Markdown.
Do I need the paid extensions?
No — everything in this guide is free. Microsoft's Python, Pylance, and Black Formatter are all no-cost.
Why does my terminal not activate the venv automatically?
VS Code usually auto-activates the selected interpreter's venv in new terminals. If it doesn't, the activation is one command away — and the interpreter selection (Step 2) is what drives it.