Two ways to automatically generate requirements.txt for Python projects

  • Output the current environment directly using PIPAll packages installedTo the requirements,
    • pip freeze > requirements.txt
  • Install pipreqs and use pipreQS outputPackages that the current project depends onTo the requirements,
    • pip install pipreqs
    • pipreqs ./

It is also easy to install dependencies in one click by reading requirements.txt: PIP install -r requirements.txt