Automatically generate requirements.txt for pip

pip is popular package manager for Python.

There is often a requirements.txt file in lots of Python projects specifying several dependencies need to install.
We can install several packages using pip at once using following command

pip -r requirements.txt

to generate requirements for pip, certainly we can type the required package names line by line,
but there is a tool called pipreqs can help us.

pipreqs

pipreqs can analyze your python project for dependencies and generate requirements.txt
used by pip automatically.

Installation

pip install pipreqs

Generate requirements.txt

pipreqs .

This command will generate requirements.txt using current directory as source root directory.
Then you can run pip -r requirements.txt to install dependencies.