Install Packages Using PIP With requirements.txt File in Python
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:
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.
A menu similar to this would have appeared. Now type in cmd
Results similar to this will be shown. Now select the cmd.exe option and select Run as administrator.
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:
Therefore, the command would be:
pip install -r "C:\requirements.txt"
In this way, you can download packages in batches in Python.
Please Login to comment...