Session 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 session 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 or on
separate lines
# 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.6 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
Step 5: Set Python Version#
Ensure that pyenv
uses the correct Python version:
pyenv global system 3.12
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 PATH
before clickingInstall Now
.If you forget to check this box, you can re-run the installer and select the option.
Step 2: Install Git#
Download Git from Git’s official website.
Choose the 64-bit version (unless you have a specific reason not to).
Avoid the portable version.
Follow the default installation options, except:
Optionally disable Explorer integration (to avoid extra right-click menu items).
Change the default editor from
Vim
toNotepad
(orNotepad++
if already installed).Disable
View Release Notes
before finishing installation.
Set Up the Module Files & Packages#
Step 1: Download Module Files#
Create a
PHAR2062
folder in a convenient location (e.g.,Desktop
).Open a terminal window
Windows: Open Windows PowerShell by searching for it in the Start menu.
Navigate to your
PHAR2062
folder usingcd
:# For example, if you created the folder on your desktop: cd Desktop\PHAR2062
Clone the course repository using Git (don’t worry about what this means yet):
# This will download the files into a folder called "phar2062-workshops" inside of the folder from which you ran this command git clone https://github.com/UoN-Chemistry/phar2062-workshops.git
Step 2: Install Required Packages#
Within your terminal, navigate into the folder created by the
git clone
command in step 1Hint: use
cd
Run the following command to install necessary Python modules:
python -m pip install .
Install Jupyter Notebook with:
pip install notebook
Summary#
By completing this session, you have:
Installed Python 3.12.
Installed Git (for Windows users).
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!