From 235e6eae440522ebce1e798292a26512630a6834 Mon Sep 17 00:00:00 2001 From: Real Python Bot <42617967+realpython-bot@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:55:04 +0000 Subject: [PATCH] Pin the python-statistics requirements Materials folders should pin their dependencies in requirements.txt, which is what the great majority of folders here already do. This one shipped with an unpinned requirements.txt and the pins kept separately in a constraints.txt, so a plain `pip install -r requirements.txt` could pull a stack the tutorial was never checked against. Move the pins into requirements.txt, drop constraints.txt, and update the README's setup step to match. Re-verified after the change: a virtualenv built from requirements.txt alone resolves to NumPy 2.5.3, SciPy 1.18.1, pandas 3.0.5 and Matplotlib 3.11.2, all 13 scripts run on it, and ruff format/check pass. Co-Authored-By: Claude Opus 5 (1M context) --- python-statistics/README.md | 4 ++-- python-statistics/constraints.txt | 4 ---- python-statistics/requirements.txt | 8 ++++---- 3 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 python-statistics/constraints.txt diff --git a/python-statistics/README.md b/python-statistics/README.md index 143a724ca1..1e3ff4e45d 100644 --- a/python-statistics/README.md +++ b/python-statistics/README.md @@ -11,10 +11,10 @@ Create and activate a virtual environment, then install the requirements: ```bash $ python -m venv venv $ source venv/bin/activate -(venv) $ python -m pip install -r requirements.txt -c constraints.txt +(venv) $ python -m pip install -r requirements.txt ``` -The tutorial's examples were verified against the versions pinned in `constraints.txt`. Newer releases will usually work too, but NumPy 2 changed how scalars are displayed, so output from older versions won't match the tutorial exactly. +`requirements.txt` pins the versions the tutorial's examples were verified against. Newer releases will usually work too, but NumPy 2 changed how scalars are displayed, so output from older versions won't match the tutorial exactly. ## Usage diff --git a/python-statistics/constraints.txt b/python-statistics/constraints.txt deleted file mode 100644 index 9a278490b4..0000000000 --- a/python-statistics/constraints.txt +++ /dev/null @@ -1,4 +0,0 @@ -numpy==2.5.3 -scipy==1.18.1 -pandas==3.0.5 -matplotlib==3.11.2 diff --git a/python-statistics/requirements.txt b/python-statistics/requirements.txt index 7bd7c445cc..9a278490b4 100644 --- a/python-statistics/requirements.txt +++ b/python-statistics/requirements.txt @@ -1,4 +1,4 @@ -numpy -scipy -pandas -matplotlib +numpy==2.5.3 +scipy==1.18.1 +pandas==3.0.5 +matplotlib==3.11.2