pip
pip3 install pipreqs
Create a new directory and put all the python files that you want to base on.
Run the below command after specifying the directory created in step 2
.
pipreqs ./req
4.New requirements.txt
file will be generated in the directory. Copy and paste or replace the file with the existing requirements.txt.
It may give you a false positive: if the name of the library has changed, it will download the version of that library that used the old name.