从一个或多个需求文件安装来自多个服务器的软件包 [英] Installing Packages from Multiple Servers from One or More Requirements File
问题描述
我尝试了以下两种方法都没有成功.
I have tried the following two approaches without success.
第一个使用级联需求文件.
The first with Cascading Requirements Files.
# requirements.txt
-r requirements/req2.txt
-r requirements/req3.txt
# requirements/req2.txt
Django==1.7.7
# requirements/req3.txt
-i https://testpypi.python.org/pypi
foo-bar==0.4
pip install -r requirements.txt
导致 pip
找不到 Django.
pip install -r requirements.txt
results in pip
not finding Django.
第二次尝试是在一个文件中包含这两个要求:
The second attempt was to include both requirements in a single file:
-i https://pypi.python.org/pypi/
Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4
pip install -r requirements.txt
导致同样的错误,pip
没有找到 Django.
pip install -r requirements.txt
results in the same error, pip
not finding Django.
如何使用 pip
安装来自不同服务器/索引 URL 的软件包?
How can I use pip
to install packages from different servers/index-urls?
推荐答案
无论哪种情况,解决方案都是在 --extra-index-url
的开头添加>requirements.txt 文件.
The solution in either case is to add --extra-index-url <url>
at the beginning of the requirements.txt
file.
示例:
# requirements.txt
--extra-index-url https://testpypi.python.org/pypi
Django==1.7.7
django-stackexchange-feed==0.4
或者使用级联需求文件:
Or to use Cascading Requirements Files:
# requirements.txt
--extra-index-url https://testpypi.python.org/pypi
-r requirements/req2.txt
-r requirements/req3.txt
# requirements/req2.txt
Django==1.7.7
# requirements/req3.txt
foo-bar==0.4
pip install -r requirements.txt
现在可以工作了.
这篇关于从一个或多个需求文件安装来自多个服务器的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!