1. If you use a virtualenv environment, use pip freeze > requirements.txt directly
➜ ~ .virtualenvs/xxx/bin/pip freeze > requirements.txt
2. If virtualenv is not used, use the tool pipreqs
The advantage of this tool is that it can automatically discover which class libraries are used by scanning the project directory, and automatically generate a dependency list. The disadvantage is that there may be some deviations, which need to be checked and adjusted by yourself.
install # pip install pipreqs
Use, enter the project directory and execute # pipreqs ./ to automatically generate the requirements.txt file in the current directory