如何使用pip一次安装多个python软件包

问题:如何使用pip一次安装多个python软件包

我知道这是一种简单的方法,但是我在这里和Google上都找不到。所以我很好奇是否有办法使用pip安装多个软件包。就像是:

pip install progra1 , progra2 ,progra3 ,progra4 . 

要么:

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

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) 

回答 0

要在命令行上安装多个软件包,只需将它们作为以空格分隔的列表传递,例如:

pip install wsgiref boto

要从文本文件安装,请从pip install --help

-r FILENAME,-requirement = FILENAME

安装给定需求文件中列出的所有软件包。此选项可以多次使用。

查看有关需求文件的一般布局和语法的pip文档 -请注意,pip freeze如果需要快速的示例,则可以根据当前环境/站点程序包生成一个pip文档 -例如(基于已安装的文件wsgirefboto干净的virtualenv文件) ):

$ pip freeze
boto==2.3.0
wsgiref==0.1.2

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

回答 1

pip install -r requirements.txt

然后在requirements.txt文件中,将模块放入列表,每行列出一项。

  • 的Django = 1.3.1

  • 南方> = 0.7

  • django-debug-工具栏

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


回答 2

您可以安装称为需求文件的文本文件中列出的软件包。例如,如果您有一个名为的文件,req.txt其中包含以下文本:

Django==1.4
South==0.7.3

然后在命令行中发出:

pip install -r req.txt

pip将安装特定版本的文件中列出的软件包。

You can install packages listed in a text file called requirements file. 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.


回答 3

作为其他答案的补充,您可以使用该选项--no-cache-dir禁用pip中的缓存。使用一次安装多个软件包时,我的虚拟机崩溃了pip install -r requirements.txt。为我解决的是:

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

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

回答 4

提供与安装单个模块时相同的命令,仅通过空格分隔的格式传递它

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