Appearance
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/WSLbrew– for managing system packages on macOSpip– 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
| Task | Command | Example |
|---|---|---|
| Update package list | sudo apt update | sudo apt update |
| Upgrade installed packages | sudo apt upgrade -y | sudo apt upgrade -y |
| Install a new package | sudo apt install package_name | sudo apt install python3-pip |
| Remove a package | sudo apt remove package_name | sudo apt remove docker |
| Search for a package | apt search package_name | apt search meshio |
Tip: Always run
sudo apt update && sudo apt upgrade -ybefore 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
| Task | Command | Example |
|---|---|---|
| Install a package | brew install package_name | brew install git |
| Update and upgrade all packages | brew update && brew upgrade | — |
| Uninstall a package | brew uninstall package_name | brew uninstall wget |
| Search for a package | brew search package_name | brew 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
| Task | Command | Example |
|---|---|---|
| Install a package | pip install package_name | pip install meshio |
| Install a specific version | pip install package_name==version | pip install numpy==1.26.0 |
| Upgrade a package | pip install --upgrade package_name | pip install --upgrade matplotlib |
| Uninstall a package | pip uninstall package_name | pip uninstall fenics |
| List installed packages | pip list | — |
| Save environment | pip freeze > requirements.txt | — |
| Reinstall from file | pip install -r requirements.txt | — |
Tip: Use
pip3instead ofpipwhen working with Python 3 (which is the default for most systems today).
Virtual Environments (Recommended Practice)
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.
| Task | Command | Example |
|---|---|---|
| Create a new virtual environment | python3 -m venv env_name | python3 -m venv fenics_env |
| Activate it (WSL/macOS) | source env_name/bin/activate | source fenics_env/bin/activate |
| Deactivate the environment | deactivate | — |
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
| Purpose | Tool | Example Command |
|---|---|---|
| Install or update system tools on Ubuntu/WSL | apt | sudo apt install python3 |
| Install or update system tools on macOS | brew | brew install git |
| Install or manage Python libraries | pip | pip 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 pipThis ensures that both your system and Python environments are up-to-date and stable for running FEniCS and related tools.