Assignment 3a: Package Management Concepts
Why Package Management Matters
When you install a package, it brings its own dependencies. For example, installing requests actually installs 5 packages: certifi, charset-normalizer, idna, urllib3, and requests itself. This is called a dependency tree.
The core problem is version conflicts — Project A might need numpy 1.26 while Project B needs numpy 2.0. Installing both into the same Python environment breaks one of them.
Virtual Environments
A virtual environment gives each project its own isolated Python installation. I proved this by creating two environments with different numpy versions:
# env-numpy1 had numpy 1.26.4
# env-numpy2 had numpy 2.4.3
# Both coexisted without conflictpip vs uv Speed Comparison
I timed both package managers installing the same 4 packages:
- pip: 5.766 seconds
- uv: 1.627 seconds
uv was nearly 4x faster! uv uses a SAT solver for dependency resolution and caches aggressively.
Requirements Files
A requirements file pins exact versions so anyone can recreate the environment:
uv pip freeze > requirements.txt
uv pip install -r requirements.txtThis ensures reproducibility — the same packages, same versions, every time.