Chapter 2: Installing Python

Installing Python on Windows

face Josiah Wang

You can skip straight to the next page if you are not using Windows.

Windows does not come with a Python interpreter out of the box, so you will need to install this.

There are different ways for you to do this.

Install via Microsoft Store (easiest)

I will assume that you are using an up-to-date version of Windows 10 or Windows 11.

Option 1

Visit the Microsoft Store (from the Start Menu), search for Python 3.12, and install it from there.

Option 2

Type python or python3 into the Command Prompt (Windows button, then type cmd) or Windows Powershell. Windows will automatically redirect you to the Microsoft Store if Python is not yet installed. Make sure that the Python version is 3.12 or above.

Download from python.org and install

Download the appropriate Python installer from the official python.org website.

Run the installer to install Python on your machine.

Check “Add Python 3.12 to PATH” when you install. This will allow you to run Python from the command line (something we will be doing quite a lot).

Use Windows Subsystem for Linux

This is for the techie amongst you!

If you are using the latest version of Windows 10 or Windows 11, you can install a virtual Linux bash shell on Windows via what is known as Windows Subsystem for Linux (WSL, more precisely WSL2). This will allow you to run Linux in a terminal directly on Windows, even directly on your files on Windows. You can even run selected Linux Graphical apps from Windows.

You will first need to set up WSL2 on your computer. You can then install Python on Linux as instructed on the next page.

This is a good way to start getting used to using Linux machines and command lines - you might have to run experiments remotely on the departmental/College Linux machines during your degree!

The lab machines in the department are expected to run on Ubuntu 24.04 by September 2024, so ideally your WSL2 installation should use this distribution by default.

The easiest way to install WSL2 on Windows is via the Microsoft Store. Launch Microsoft Store, and search for “Windows Subsystem for Linux”.

Alternatively, follow the instructions on this page if you would like to install WSL2 on Windows. Then install Python according our instructions on the Unix/Linux page.

Check installation

Once you have installed Python, launch a Windows PowerShell console (or Command Prompt). Type in the following to check that Python has been installed correctly.

PS C:\Users\username> python -V
Python 3.12.3

You can also use Windows Terminal to use the command line with multiple tabs and panes.