Skip to content

Package Management

Package management is an essential part of setting up and maintaining your simulation environment. It ensures that all required tools, libraries, and dependencies are installed correctly and kept up to date — whether they are system-level packages or Python libraries.

In Linux (WSL/Ubuntu) and macOS, three main package managers are commonly used:

  • apt – for managing system packages on Ubuntu/WSL
  • brew – for managing system packages on macOS
  • pip – for managing Python libraries

1. Using apt (Ubuntu / WSL)

apt (Advanced Package Tool) manages software and dependencies for Ubuntu and WSL environments. You’ll use it to install system utilities, compilers, and core tools such as Python, Git, and Docker.

Common Commands

TaskCommandExample
Update package listsudo apt updatesudo apt update
Upgrade installed packagessudo apt upgrade -ysudo apt upgrade -y
Install a new packagesudo apt install package_namesudo apt install python3-pip
Remove a packagesudo apt remove package_namesudo apt remove docker
Search for a packageapt search package_nameapt search meshio

Tip: Always run sudo apt update && sudo apt upgrade -y before installing new packages to make sure your package list is current.

2. Using brew (macOS)

For macOS, Homebrew (or simply brew) is the package manager equivalent to apt. It allows you to install software and libraries that aren’t available by default on macOS.

Installing Homebrew

If you don’t already have it, install Homebrew using:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Common Commands

TaskCommandExample
Install a packagebrew install package_namebrew install git
Update and upgrade all packagesbrew update && brew upgrade
Uninstall a packagebrew uninstall package_namebrew uninstall wget
Search for a packagebrew search package_namebrew search python

3. Using pip (Python Packages)

While apt and brew manage software at the system level, pip is used to install and manage Python libraries — which you’ll need for simulations, scientific computing, and automation.

Common Commands

TaskCommandExample
Install a packagepip install package_namepip install meshio
Install a specific versionpip install package_name==versionpip install numpy==1.26.0
Upgrade a packagepip install --upgrade package_namepip install --upgrade matplotlib
Uninstall a packagepip uninstall package_namepip uninstall fenics
List installed packagespip list
Save environmentpip freeze > requirements.txt
Reinstall from filepip install -r requirements.txt

Tip: Use pip3 instead of pip when working with Python 3 (which is the default for most systems today).

When working on multiple projects, it’s best to use virtual environments to isolate Python dependencies. This prevents version conflicts and ensures reproducibility across simulations.

TaskCommandExample
Create a new virtual environmentpython3 -m venv env_namepython3 -m venv fenics_env
Activate it (WSL/macOS)source env_name/bin/activatesource fenics_env/bin/activate
Deactivate the environmentdeactivate

Why Package Management Matters

  • Ensures all required tools and libraries are installed correctly.
  • Automatically handles dependencies between software packages.
  • Keeps your system and Python environment consistent and reproducible.
  • Simplifies installation of scientific and simulation-related packages like FEniCS, NumPy, Matplotlib, and meshio.

Summary

PurposeToolExample Command
Install or update system tools on Ubuntu/WSLaptsudo apt install python3
Install or update system tools on macOSbrewbrew install git
Install or manage Python librariespippip install numpy

Together, these three package managers keep your system and environment organized, consistent, and ready for simulation work.

Before starting any new project, it’s a good habit to run:

sudo apt update && sudo apt upgrade -y
pip install --upgrade pip

This ensures that both your system and Python environments are up-to-date and stable for running FEniCS and related tools.