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 <noreply@anthropic.com>
This commit is contained in:
2026-07-05 09:45:51 +00:00
parent bfbeb9fc7f
commit 6232887ebd
3 changed files with 7 additions and 18 deletions
+3 -8
View File
@@ -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