Generate requirements.txt
Generate requirements.txt is a reusable Python snippet. Generate a requirements.txt file from the current environment or freeze installed packages for deployment. The full implementation: # Generate requirements.txt (all packages) pip freeze > requirements.txt # List only dependencies of a specific project pip list --format=freeze > requirements.txt # Install from requirements.txt pip install -r requirements.txt # Generate with pipreqs (only used packages) # pip install pipreqs # pipreqs /path/to/project # Example requirements.txt # requests==2.31.0 # flask==3.0.0 # numpy==1.26.0 It belongs to the Sys Module area of the standard library. This snippet uses only the Python standard library with no third-party dependencies, so it runs on any modern Python 3 interpreter. Browse more patterns in the snippet library, or paste the code straight into the playground to experiment with it.