From 6232887ebdda4f14f7add5c4e64dc0a31d062e33 Mon Sep 17 00:00:00 2001 From: Linghong Date: Sun, 5 Jul 2026 09:45:51 +0000 Subject: [PATCH] Pin opencv-python-headless in requirements The GUI opencv-python build needs libGL.so.1 which headless Linux servers lack, causing "ImportError: libGL.so.1" at first cv2 use. Pin the headless build so a plain `pip install -r requirements.txt` works on servers out of the box (and survives a git reset). BgFilter only uses cv2 for computation, so headless is a drop-in on desktops too. Drop the now-unnecessary sed step from DEPLOY. Co-Authored-By: Claude Opus 4.8 --- DEPLOY.md | 12 +++--------- DEPLOY_ZH.md | 11 +++-------- requirements.txt | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/DEPLOY.md b/DEPLOY.md index 2d42c2a..e5d1d6a 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -53,15 +53,9 @@ the default CUDA build and ~2–3 GB of `nvidia-*` packages you don't need on a pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu ``` -On a headless server use **`opencv-python-headless`** instead of `opencv-python` -(the GUI build needs `libGL.so.1` etc. that servers usually lack): - -```bash -sed -i 's/^opencv-python$/opencv-python-headless/' requirements.txt -``` - -Then install the rest. `torch`/`torchvision` are already satisfied, so this won't -re-pull CUDA: +`requirements.txt` already pins **`opencv-python-headless`** (the GUI build needs +`libGL.so.1` etc. that headless servers lack), so no change is needed. Then install +the rest — `torch`/`torchvision` are already satisfied, so this won't re-pull CUDA: ```bash pip install -r requirements.txt diff --git a/DEPLOY_ZH.md b/DEPLOY_ZH.md index 238c08f..dc5e091 100644 --- a/DEPLOY_ZH.md +++ b/DEPLOY_ZH.md @@ -49,14 +49,9 @@ python -m pip install -U pip pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu ``` -无 GUI 的服务器请用 **`opencv-python-headless`** 代替 `opencv-python`(GUI 构建依赖 -`libGL.so.1` 等服务器通常没有的库): - -```bash -sed -i 's/^opencv-python$/opencv-python-headless/' requirements.txt -``` - -再装其余依赖。此时 `torch`/`torchvision` 已满足,不会再拉 CUDA: +`requirements.txt` 里已经固定用 **`opencv-python-headless`**(GUI 构建依赖 `libGL.so.1` +等无头服务器没有的库),所以无需改动。直接装其余依赖——此时 `torch`/`torchvision` +已满足,不会再拉 CUDA: ```bash pip install -r requirements.txt diff --git a/requirements.txt b/requirements.txt index 7ed5b5a..566302f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -opencv-python +opencv-python-headless pillow numpy scipy