Python Development in VS Code
With the Python extension installed, VS Code becomes a full-featured Python IDE. This lesson covers virtual environments, Pylance, Jupyter, and debugging Python code.
1Installing the Python Extension
Search for Python in the Extensions view and install the Microsoft Python extension. This bundles Pylance (the language server), the Python debugger, and Jupyter notebook support.
2Virtual Environments & Interpreter Selection
Press Ctrl+Shift+P → Python: Create Environment to create a venv or conda environment. VS Code detects it automatically. The selected interpreter is shown in the Status Bar — click it to switch.
python -m venv .venv # VS Code activates it automatically in new terminals pip install fastapi uvicorn
3Pylance & Type Checking
Pylance provides fast, type-aware IntelliSense including auto-imports, signature help, hover docs, and inlay type hints. Enable strict mode in pyrightconfig.json:
{ "typeCheckingMode": "strict", "pythonVersion": "3.12" }
4Running & Debugging Python
Click the Run Python File button in the top-right, or press F5 with a launch.json. Set breakpoints anywhere; VS Code's debugger shows the call stack, local variables, and a watch panel. The Python debugger also supports Remote Attach for debugging running servers.
5Jupyter Notebooks
Open any .ipynb file and VS Code displays it as an interactive notebook. Run cells with Shift+Enter, view rich outputs inline, and use Copilot for cell completions. Export to .py or share via Codespaces.