CLI Reference

Basic Usage

depwhy is invoked as:

depwhy [SOURCE]

or

depwhy --env

SOURCE can be:

  • A requirements.txt file
  • A pyproject.toml file

Scanning a requirements.txt

$ depwhy requirements.txt
2 conflict(s) found
urllib3
Problem: requests==2.28.0 requires urllib3>=1.21.1,<1.27, but you have urllib3==2.0.0 pinned
Solution: Remove your pin — use urllib3==1.26.18 (latest compatible)
→ pip install urllib3==1.26.18
Alternative: Upgrade requests to >=2.29.0 (loosens urllib3 upper bound)
→ pip install requests==2.29.0

Scanning a pyproject.toml

$ depwhy pyproject.toml
1 conflict(s) found
numpy
Problem: scikit-learn==1.2.0 requires numpy>=1.22.4, but you have numpy==1.21.0 pinned
Solution: Upgrade numpy to satisfy scikit-learn's constraint
→ pip install numpy==1.22.4
Alternative: Downgrade scikit-learn to a version compatible with numpy==1.21.0
→ pip install scikit-learn==1.1.3

Scanning a virtual environment

$ depwhy --env
✓ No conflicts found

Exit Codes

| Code | Meaning | Example | |------|---------|---------| | 0 | No conflicts detected | depwhy clean-requirements.txt | | 1 | At least one conflict found | depwhy conflicting-requirements.txt | | 2 | Usage error or runtime error | depwhy nonexistent.txt |

Checking exit codes

$ depwhy requirements.txt --quiet; echo "Exit code: $?"
Exit code: 1
$ depwhy clean-requirements.txt --quiet; echo "Exit code: $?"
Exit code: 0

Error handling

Exit code 2 is returned for usage errors and runtime errors.

$ depwhy nonexistent.txt
Error: File not found: nonexistent.txt
$ depwhy
Error: Provide a SOURCE file or use --env.

Use --quiet in CI pipelines to suppress all output and rely solely on the exit code. This pairs well with shell conditionals like if depwhy requirements.txt --quiet; then ....