Open In App

How to install Python packages with requirements.txt

Improve
Improve
Like Article
Like
Save
Share
Report

Python package is a container for storing multiple Python modules. We can install packages in Python using the pip package manager. In this article, we will learn to install multiple packages at once using the requirements.txt file. We will use the pip install requirements.txt command to install Python packages. The requirements.txt file is useful to install all packages at once for a project, it is easy to hand over to other developers and we can use this to install different versions of packages for different Python projects.

The classic way of installing packages in Python using pip:

pip install package_name1, package_name2

Installing Python Packages using requirements.txt file

Here, we will see how to install Python packages using pip install requirements.txt. We will define each package in a new line in the requirements.txt file.

Let’s say below the three Python packages we defined in the requirements.txt file.

  • Pandas
  • Pillow
  • Numpy

We will install packages using the below command. Run the below command where the requirements.txt file is present.

pip install -r requirements.txt

PIP will download and install all packages present in that file.


Last Updated : 24 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads