VSCode Python Configuration Guide

Overview

This guide will help you configure Visual Studio Code to use the latest Python version installed on your Mac.



Step 1: Install the Python Extension

  1. Open VSCode
  2. Click the Extensions icon in the left sidebar (or press Cmd + Shift + X)
  3. Search for "Python" (the official one by Microsoft)
  4. Click Install

This extension provides syntax highlighting, debugging, linting, and intellisense for Python.



Step 2: Select Your Python Interpreter

  1. Press Cmd + Shift + P to open the Command Palette
  2. Type "Python: Select Interpreter" and press Enter
  3. You'll see a list of available Python versions on your machine
  4. Select the latest version (should be Python 3.13 or your preferred version)
    • Look for the one in /opt/homebrew/bin/python3.13

Note: If you don't see your Python version listed, click "Enter interpreter path" and manually type the full path.



Step 3: Verify Your Selection

  1. Open VSCode's integrated Terminal: Ctrl + ` (backtick)
  2. Run the following commands:
python3 --version
which python3

Both should confirm you're using the correct version (e.g., 3.13).



Step 4: Set as Default (Optional)

To make this your permanent default interpreter:

  1. Press Cmd + , to open Settings
  2. Search for "python.defaultInterpreterPath"
  3. Set the value to your Python path, for example:
    /opt/homebrew/bin/python3.13
    


Step 5: Install Useful Extensions (Optional)

Consider installing these additional extensions for better development experience:

  • Pylint – Code linting and error detection
  • Black Formatter – Automatic code formatting
  • Jupyter – If you work with notebooks
  • Git Graph – Better git visualization


Step 6: Configure Python Linting (Optional)

  1. Press Cmd + , to open Settings
  2. Search for "python.linting"
  3. Choose your preferred linter (pylint, flake8, etc.)
  4. Enable it by checking the box


Verification Checklist

  • [ ] Python extension installed
  • [ ] Correct interpreter selected (3.13 or latest)
  • [ ] Terminal shows correct Python version
  • [ ] Can run Python scripts without errors
  • [ ] IntelliSense is working (autocomplete suggestions appear)


Common Issues & Solutions

Issue: Python not found in terminal

Solution: Make sure you've added Python to your PATH in ~/.zshrc:

export PATH="/opt/homebrew/bin:$PATH"

Issue: VSCode still shows old Python version

Solution:

  1. Restart VSCode completely (Cmd + Q, then reopen)
  2. Clear the Python extension cache: Delete ~/.vscode/extensions/ms-python.python-*
  3. Re-select the interpreter

Issue: Packages installed but not recognized

Solution: Install them in the same Python environment:

python3 -m pip install package_name



Useful VSCode Shortcuts

  • Cmd + Shift + P – Command Palette
  • Ctrl + ` – Toggle integrated Terminal
  • Cmd + , – Open Settings
  • Cmd + K Cmd + T – Select color theme
  • Cmd + Shift + X – Open Extensions


Next Steps

  1. Create a test Python file: test.py
  2. Add some code:
    print("Hello, Python 3.13!")
    
  3. Run it: Ctrl + F5 or right-click and select "Run Python File in Terminal"

You're all set! Happy coding!