Method one PIP Freeze

pip freeze > requirements.txt
Copy the code

In this way, all dependencies in the environment will be added. If the global environment is used, all downloaded packages will be included, regardless of the dependencies of the current project. So method one applies to a clean virtual environment

Method 2 pipreqs

pip install pipreqs
# --forece overwrites the original requirements.txt
pipreqs . --encoding=utf-8 --force
Copy the code

Use requirements. TXT

pip install -r requirements.txt
Copy the code

END ( ・´ω`・ )