Python_VSCode_Setup_Guide

Installing Python and VS Code

DSB102 Introduction to Machine Learning | S2 2026

This guide gets your own laptop ready for the workshops and the Lab Assessment. You need two things installed: Python (the language) and VS Code (the editor you’ll write and run it in). Do this before your first workshop if you can — it takes about 15–20 minutes.

You only need to do this once. The lab computers already have everything installed, so this guide is for your own laptop only.


Step 1 — Install Python

Windows

  1. Go to python.org/downloads and click the yellow “Download Python” button.

  2. Run the installer.

  3. Important: on the very first screen, tick the box at the bottom that says “Add python.exe to PATH”. This is the single most common thing people forget, and it will cause problems later if you skip it.

  4. Click Install Now and let it finish.

  5. Check it worked: open the Start Menu, type cmd, press Enter to open Command Prompt, then type:

    python --version

    You should see something like Python 3.12.x. If instead you get “not recognised”, see Troubleshooting below.

Mac

  1. Go to python.org/downloads and download the macOS installer (the yellow button).

  2. Open the downloaded .pkg file and go through the installer with the default options.

  3. Check it worked: open Terminal (press Cmd+Space, type “Terminal”, press Enter), then type:

    python3 --version

    You should see something like Python 3.12.x. On a Mac, always use python3, not python — plain python may point to an old system version or nothing at all.


Step 2 — Install VS Code

Same for both Windows and Mac:

  1. Go to code.visualstudio.com and click the big Download button — it will detect your operating system automatically.
  2. Run the installer with the default options.
  3. Open VS Code once it’s installed to confirm it launches.

Step 3 — Install the VS Code extensions

Inside VS Code:

  1. Click the Extensions icon in the left-hand sidebar (it looks like four small squares, one detached).
  2. Search for “Python” (published by Microsoft) and click Install.
  3. Search for “Jupyter” (published by Microsoft) and click Install.

That’s it — these two extensions let VS Code run both .ipynb notebooks and .py files cell-by-cell.


Step 4 — Install the Python packages you’ll need

Open a terminal inside VS Code: menu Terminal → New Terminal. Then run:

Windows:

pip install numpy pandas matplotlib scikit-learn scipy statsmodels jupyter

Mac:

pip3 install numpy pandas matplotlib scikit-learn scipy statsmodels jupyter

This will take a minute or two. A few weeks (e.g. the neural networks workshop) need one extra package, tensorflow — you’ll be told when that’s needed, and the same pip/pip3 install pattern applies.


Step 5 — Test that everything works

  1. Create a new file called test.py anywhere convenient (e.g. your Desktop) and open it in VS Code.

  2. Type the following into it:

    # %%
    import pandas as pd
    import matplotlib.pyplot as plt
    
    df = pd.DataFrame({"x": [1, 2, 3], "y": [4, 9, 16]})
    print(df)
    df.plot(x="x", y="y", marker="o")
    plt.show()
  3. VS Code should show a “Run Cell” link just above the # %% line — click it (or press Shift+Enter).

  4. The first time you run a cell, VS Code may ask you to select a Python interpreter — choose the one that shows a version number (e.g. “Python 3.12.x”).

  5. You should see a small table printed and a line chart appear in a new panel.

If you see the table and the chart, you’re fully set up. Delete test.py — it was only for testing.


Troubleshooting

Problem Fix
Windows: 'python' is not recognized as an internal or external command You likely missed the “Add python.exe to PATH” checkbox during install. Uninstall Python, reinstall, and make sure to tick that box this time.
Mac: command not found: python Use python3 instead of python — this is normal and expected on a Mac. Same for pip3 instead of pip.
VS Code doesn’t show “Run Cell” above # %% The Jupyter extension isn’t installed, or VS Code needs a restart after installing it. Check Step 3.
Running a cell asks you to “select a kernel” or “select interpreter” and nothing shows up Python itself isn’t installed correctly, or VS Code can’t find it — redo Step 1, then fully close and reopen VS Code.
pip install fails with a permissions error Add --user to the command, e.g. pip install --user numpy pandas matplotlib scikit-learn scipy statsmodels jupyter.
ModuleNotFoundError: No module named 'pandas' (or similar) when running a cell The packages installed to a different Python than the one VS Code is using. Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) → “Python: Select Interpreter” and make sure the same Python version is selected everywhere, then reinstall the packages from Step 4 using that interpreter’s terminal.

Getting help

If you’re stuck after trying the table above, bring your laptop to the next workshop — setup help is part of what the early workshops are for — or post your exact error message on the Canvas discussion board.

This setup is required for the workshops and for the Lab Assessment, which is done in VS Code (not Google Colab or Jupyter in a browser).