You can run Python right here in the browser, but for real projects you'll want it installed locally. This guide takes you from zero to running, debugging and packaging Python in VS Code.

Install Python

  • Windows: download from python.org and tick "Add python.exe to PATH" during install.
  • macOS: brew install python (Homebrew) or download the python.org installer.
  • Linux: usually preinstalled. Otherwise sudo apt install python3 python3-venv python3-pip.

Verify it: python3 --version

Install VS Code and the Python extension

Download VS Code from code.visualstudio.com, then install the Python extension by Microsoft (it bundles Pylance for IntelliSense). Open your project folder, press Ctrl+Shift+P → "Python: Select Interpreter" and pick your installed Python.

Write and run

Create hello.py:

def greet(name):
    return f"Hello, {name}!"

print(greet("Ada"))

Click the ▶ Run button (top-right) or run it in the integrated terminal:

python3 hello.py

Debug it

Set a breakpoint by clicking in the gutter to the left of a line number, then press F5 and choose "Python File". Execution pauses at the breakpoint so you can inspect variables, step over (F10) and step into (F11) calls.

Isolate dependencies and package

Use a virtual environment so each project has its own packages:

python3 -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install requests
pip freeze > requirements.txt

Anyone can then reproduce your setup with pip install -r requirements.txt. To ship a standalone app, tools like PyInstaller (pip install pyinstaller && pyinstaller --onefile hello.py) bundle Python and your code into a single executable.