Open In App

Install Packages Using PIP With requirements.txt File in Python

Improve
Improve
Like Article
Like
Save
Share
Report

Installing more than one package in Python simultaneously is a common requirement for any user migrating between operating systems. Most users are unaware of the availability of batch installing all the packages. They default to manually installing each library one after the other, which is time-consuming. This article will teach you how to install packages using pip according to the requirements.txt file from a local directory.

For installing packages from the file, the requirements.txt file would contain the following text:

Install Packages Using PIP With  requirements.txt File in Python

 

Copy the full path (absolute path) to the requirements.txt file.

Now open the command processor of your operating system. For Windows, click on the bottom left of the desktop or press the [Win] key.

Install Packages Using PIP With  requirements.txt File in Python

 

A menu similar to this would have appeared. Now type in cmd

Install Packages Using PIP With  requirements.txt File in Python

 

Results similar to this will be shown. Now select the cmd.exe option and select Run as administrator. 

Install Packages Using PIP With  requirements.txt File in Python

 

Install Packages Using PIP With  requirements.txt File in Python

 

A new window similar to the above would have appeared. Now enter the following command:

pip install -r "_Path_to_requirements.txt"

Where _Path_to_requirements.txt is the full path of the file. In this case, the file resides at the following location:

C:\requirements.txt

Therefore, the command would be:

pip install -r "C:\requirements.txt"
Install Packages Using PIP With  requirements.txt File in Python

 

In this way, you can download packages in batches in Python.


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