Topic 0: Installing Python and Required Software#
Introduction#
Before we begin our Python programming journey, we need to ensure that our systems have the necessary software installed. This section provides step-by-step instructions for installing Python and related tools on both macOS and Windows.
Throughout the module you will invariably need to use the terminal or command line to run programs, so you might find the cheatsheet below a useful bookmark:
You will also see a lot of code boxes in the text that look like this:
# Hover your mouse to show a button that will copy this into your clipboard!
These are here to symbolize commands you can either copy into your terminal or into your program code.
Installing Python and Required Tools on macOS#
If you are using a Mac, follow these steps to install Python 3.12.11 and Jupyter Notebook:
Step 1: Install Homebrew#
Homebrew is a package manager for macOS that makes it easier to install software. Run the following command in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
You should carefully read the output text in the terminal and run any follow-up commands it asks you to in order to complete the setup.
Step 2: Install pyenv#
pyenv allows us to manage multiple versions of Python. Install it using:
brew install pyenv
Step 3: Ensure pyenv is on the Path#
Run the following command to update your shell configuration:
echo 'export PATH="$HOME/.pyenv/shims:$PATH"' > ~/.zshrc
Then, restart your shell:
exec $SHELL
Step 4: Install Python 3.12#
Now, use pyenv to install the recommended Python version:
pyenv install 3.12.11
Step 5: Set Python Version#
Ensure that pyenv uses the correct Python version:
pyenv global system 3.12.11
Installing Python and Required Tools on Windows#
If you are using Windows, follow these steps to install Python 3.12 and related tools:
Step 1: Install Python#
Download Python 3.12 from Python’s official website.
On the website, avoid the default Python 3.13 download. Instead, go to Downloads → Windows and select Python 3.12 (64-bit installer).
While Python is almost always backwards-compatible, the module has been designed with version 3.12 in mind.
Run the installer and ensure you check the box
Add python.exe to PATHbefore clickingInstall Now.If you forget to check this box, you can re-run the installer and select the option.
Set Up the Module Files & Packages#
Step 1: Download Module Files#
Create a
PHAR2062folder in a convenient location (e.g.,Desktop).From the Moodle site download the zip file labelled “Files and Folders for the Module” and then move it from your Downloads folder (where you will see it with the name
phar2062-workshops.zip) to thePHAR2062folder you have just created.Double-click on the zip file to unpack the contents. You should see a new sub-folder called
phar2062-workshops-main.You can now delete the zip file.
Step 2: Install Required Packages#
Within your terminal, navigate into your
PHAR2062folderHint: use
cd
Run the following command to install necessary Python modules:
pip install notebook
Summary#
By completing this topic, you have:
Installed Python 3.12.
Set up necessary module files for the course.
Installed Jupyter Notebook, which will be used throughout the workshops.
Now, you are ready to start programming in Python!