pip-check-reqs

raw JSON →
2.5.6 verified Fri May 01 auth: no python

A tool to find packages that should or should not be in requirements for a Python project. It checks for missing dependencies (packages imported but not listed) and unused packages (listed but not imported). Current version 2.5.6, requires Python >=3.9, actively maintained.

pip install pip-check-reqs
error pip._vendor.pkg_resources.RequirementParseError: Invalid requirement, parse error in ...
cause Invalid syntax or malformed line in requirements.txt (e.g., missing version specifier).
fix
Fix the requirements file to comply with PEP 508 format. Example: 'package>=1.0' not 'package >=1.0' with extra spaces.
error ModuleNotFoundError: No module named 'some_package'
cause The tool cannot find an imported module in the environment because it is not installed.
fix
Install the missing package via pip install some_package or add it to requirements.txt.
error pip_check_reqs.exceptions.PackageNotFoundError: Package 'some-package' not found in environment
cause The package listed in requirements.txt is not installed in the current environment.
fix
Run pip install -r requirements.txt to install all listed packages.
gotcha The tool only analyses static imports as reported by `pip freeze` and static analysis of import statements. Dynamic imports (e.g., `importlib.import_module()`) are not detected. You may miss dependencies if your code uses dynamic imports.
fix Manually verify dynamic imports or use a more comprehensive tool like `pip-audit` or `safety`.
gotcha Running `pip-check-reqs` on a project without first installing all dependencies in the same environment will give false positives/negatives. The tool relies on locally installed packages to match against imports.
fix Always run in a virtual environment where all project dependencies are installed via `pip install -r requirements.txt`.
deprecated The `--requirements` flag is deprecated in favor of `-r`. In version 2.5.6, `--requirements` still works but may be removed in the future.
fix Use `pip-check-reqs check-requirements -r requirements.txt` instead of `--requirements requirements.txt`.

Basic usage: check for missing dependencies and find unused packages in a requirements file.

pip install pip-check-reqs
pip-check-reqs check-requirements -r requirements.txt
pip-check-reqs find-unused -r requirements.txt