Skip to content

fix(deps): make a fresh pip install importable with PytorchWildlife 1.3.1 - #8

Open
Zhongqi Miao (zhmiao) wants to merge 1 commit into
microsoft:mainfrom
zhmiao:fix/pw-1.3.1-install
Open

Zhongqi Miao (zhmiao) wants to merge 1 commit into
microsoft:mainfrom
zhmiao:fix/pw-1.3.1-install

Conversation

@zhmiao

@zhmiao Zhongqi Miao (zhmiao) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Why

The README's pip install path (pip install -r requirements.txt) gives an environment where python main.py --help fails at import. main.py imports src/utils/batch_detection_cropping.py, which imports PytorchWildlife, and PytorchWildlife 1.3.1 (its final release) cannot be imported from a clean install. A fresh Python 3.11 venv failed in this order:

  1. ModuleNotFoundError: No module named 'soundfile', from PytorchWildlife/data/bioacoustics/bioacoustics_annotations.py.
  2. ModuleNotFoundError: No module named 'librosa', from PytorchWildlife/data/bioacoustics/bioacoustics_spectrograms.py.
  3. ModuleNotFoundError: No module named 'pkg_resources', from yolov5/utils/general.py.
    • setuptools 81.0.0 still ships pkg_resources; 82.0.0 does not. Both were checked in this venv.
    • PytorchWildlife 1.3.1 declares plain setuptools, so pip resolves the latest release (84.2.1).

PytorchWildlife is retired, so this cannot be fixed upstream. This repo has to declare the gaps itself.

What

requirements.txt gains:

soundfile
librosa
# PytorchWildlife 1.3.1 imports yolov5, which imports pkg_resources (removed in setuptools 82)
setuptools<82

environment.yaml is unchanged. It is a frozen Python 3.8 snapshot with pytorchwildlife==1.0.1.1 and setuptools=69.0.3, so it does not hit these errors.

Trade-off to decide

setuptools<82 resolves to 81.0.0, which is inside the affected range of two open advisories:

  • GHSA-h35f-9h28-mq5c (medium): MANIFEST.in exclusion bypass when building an sdist on macOS APFS/HFS+. Patched in 83.0.0.
  • GHSA-xmj3-9gf7-h52w (low): Windows path escape during legacy wheel installation. Patched in 84.1.0.

Both affect packaging and install steps, not the training code at runtime. Dependabot will likely flag the pin.

Alternatives considered:

  • Lazy import of PytorchWildlife inside src/utils/batch_detection_cropping.py. This fixes --help and --predict only. Every train, val, and test run still calls batch_detection_cropping() (main.py, the if not conf.predict: block), which imports PytorchWildlife and yolov5, so the cap would still be needed for training.
  • Port the cropping step (MegaDetectorV5 detection plus crop) to sparrow-engine. This removes PytorchWildlife and the cap entirely. It is a larger change and belongs in its own PR.

If you prefer the port, close this PR.

How it was tested

In a fresh Python 3.11 venv (CPU torch, uv pip install -r requirements.txt), the resolver picked:

  • setuptools 81.0.0
  • PytorchWildlife 1.3.1
  • lightning and pytorch-lightning 2.6.6

python main.py --help exits 0. Without the four new lines, the same install fails with the errors listed above.

Independent of #7 (safe YAML loading and GPU list validation); the two PRs touch different files.

….3.1

PytorchWildlife 1.3.1, its final release, cannot be imported from a clean
pip install:
- it imports soundfile and librosa at package load but does not declare
  them;
- its yolov5 dependency imports pkg_resources, which setuptools removed
  in 82.0.0.

Add soundfile and librosa, and cap setuptools below 82, so the
documented `pip install -r requirements.txt` gives a working main.py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: cf871bd7-3efa-4dad-8dd6-c61e46669a42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant