You can use the following code to generate a requirements.txt file:
pip install pipreqs pipreqs /path/to/project
The benefits of using pipreqs from its GitHub.1
https://stackoverflow.com/questions/31684375/automatically-create-file-requirements-txt ↩