-->

Python - PIP Part 5: Managing Requirements with PIP

In larger projects, it’s common to create a requirements.txt file that lists all the dependencies needed for the project. PIP helps manage this file for easy installation across environments.

Example 1: Generating requirements.txt

To generate a list of all installed packages and their versions, run:

pip freeze > requirements.txt

Example 2: Installing Packages from requirements.txt

You can install all dependencies from a requirements.txt file by running:

pip install -r requirements.txt

Example 3: Specifying Package Versions in requirements.txt

You can manually edit the requirements.txt file to specify package versions, such as:

requests==2.25.0

numpy==1.19.5

Explanation:

The requirements.txt file simplifies sharing and reproducing Python environments, ensuring consistency across different setups or deployments.