How to install multiple python packages at once using pip

PythonPip

Python Problem Overview


I know it's an easy way of doing it but i didn't find it neither here nor on google. So i was curious if there is a way to install multiple packages using pip. Something like:

pip install progra1 , progra2 ,progra3 ,progra4 . 

or:

pip install (command to read some txt containing the name of the modules) 

Python Solutions


Solution 1 - Python

For installing multiple packages on the command line, just pass them as a space-delimited list, e.g.:

pip install wsgiref boto

For installing from a text file, then, from pip install --help:

>-r FILENAME, --requirement=FILENAME > >Install all the packages listed in the given requirements file. This option can be used multiple times.

Take a look at the pip documentation regarding requirements files for their general layout and syntax - note that you can generate one based on current environment / site-packages with pip freeze if you want a quick example - e.g. (based on having installed wsgiref and boto in a clean virtualenv):

$ pip freeze
boto==2.3.0
wsgiref==0.1.2

Solution 2 - Python

pip install -r requirements.txt

and in the requirements.txt file you put your modules in a list, with one item per line.

  • Django=1.3.1

  • South>=0.7

  • django-debug-toolbar

Solution 3 - Python

You can install packages listed in a text file called [requirements file][1]. For example, if you have a file called req.txt containing the following text:

Django==1.4
South==0.7.3

and you issue at the command line:

pip install -r req.txt

pip will install packages listed in the file at the specific revisions. [1]: http://pip.readthedocs.org/en/latest/user_guide.html#requirements-files

Solution 4 - Python

You can use the following steps:

Step 1: Create a requirements.txt with list of packages to be installed. If you want to copy packages in a particular environment, do this

pip freeze >> requirements.txt

else store package names in a file named requirements.txt

Step 2: Execute pip command with this file

pip install -r requirements.txt

Solution 5 - Python

On the command line if you have a few packages to install, You may just do

pip install <package_1> <package_2>

Thanks,

Solution 6 - Python

Complementing the other answers, you can use the option --no-cache-dir to disable caching in pip. My virtual machine was crashing when installing many packages at once with pip install -r requirements.txt. What solved for me was:

pip install --no-cache-dir -r requirements.txt

Solution 7 - Python

You can simply place multiple name together separated by a white space like

C:\Users\Dell>pip install markdown django-filter

#c:\Users\Dell is path in my pc this can be anything on yours

this installed markdown and django-filter on my device. enter image description here

Solution 8 - Python

give the same command as you used to give while installing a single module only pass it via space delimited format

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFlorinView Question on Stackoverflow
Solution 1 - PythonKristian GlassView Answer on Stackoverflow
Solution 2 - PythonRadu GheorghiuView Answer on Stackoverflow
Solution 3 - PythonMasciView Answer on Stackoverflow
Solution 4 - PythonshreyaskarView Answer on Stackoverflow
Solution 5 - PythonMAKView Answer on Stackoverflow
Solution 6 - PythonvictortvView Answer on Stackoverflow
Solution 7 - Pythonlearning_bunnyView Answer on Stackoverflow
Solution 8 - PythonSATYAJIT MAITRAView Answer on Stackoverflow