Skip to main content
To get the libraries used in a Python project, you can use the pipreqs tool. This tool scans your Python files and generates a requirements.txt file with the libraries used in your project.
Unlike pip freeze, which lists all packages in the current environment, pipreqs only includes packages that are actually imported in your project code.

Usage

pip install pipreqs
pipreqs /path/to/your/project --force

# verify the generated requirements.txt
cat requirements.txt
The --force flag overwrites an existing requirements.txt file if one already exists.

Build docs developers (and LLMs) love