pipreqs is a command-line tool that generates a requirements.txt file by analyzing the actual imports in a Python project rather than scanning installed packages.
The tool solves the problem of creating accurate dependency lists without needing a pre-configured environment or manual tracking. It works by scanning Python source files in a project directory, extracting import statements, and querying PyPI to determine the correct package names and versions. This approach differs fundamentally from pip freeze, which captures all installed packages regardless of whether they are actually used in the project. pipreqs identifies only the dependencies that the code explicitly imports, making it particularly useful for new projects or when working across different environments.
The tool suits developers who need to quickly generate requirements files without setting up a virtual environment first, or who want to clean up bloated dependency lists. It handles standard Python files and can optionally scan Jupyter notebooks. The project offers flexibility through options like custom PyPI servers, proxy support, different versioning schemes (compatible release, greater-than-or-equal, or unpinned), and the ability to compare or clean existing requirements files. For teams concerned about dependency bloat, the diff and clean modes help identify unused packages already listed in requirements.txt.
The project is actively maintained with automated test coverage and CI workflows in place. Development appears to have stabilized around core functionality rather than pursuing rapid feature expansion. The maintainers have explicitly indicated they are seeking additional contributors to move the project forward.