PIP:如何级联需求文件和使用私有索引?

2024-06-16 11:10:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图将Django应用程序部署到Heroku,其中一个必需的包位于https://testpypi.python.org/pypi上,当然Django在主PyPI服务器上。在

我的设置是这样的。在

# requirements.txt
-r requirements/req2.txt
-r requirements/req3.txt
^{pr2}$
# requirements/req3.txt
-i https://testpypi.python.org/pypi
foo-bar==0.4

运行命令:pip install -r requirements.txt会导致以下错误。在

Could not find any downloads that satisfy the requirement 
Django==1.7.7 (from -r ./requirements/req2.txt (line 2))
No distributions at all found for Django==1.7.7 
(from -r ./requirements/req2.txt (line 2))

所以在我看来,req3中的-i参数正在设置,然后pip试图在testpypi服务器上查找Django。在

我尝试将-i https://pypi.python.org/pypi添加到req2.txt中,但仍然得到相同的错误。(也许https://pypi.python.org/pypi是错误的url)

另外,如果我单独运行req*.txt文件,则包的安装是否成功?在

如何级联需求文件并使用私有索引?

无可否认,this question和{a2}非常相似,但都不处理私有索引


Tags: pip文件djangofromhttpsorg服务器txt
1条回答
网友
1楼 · 发布于 2024-06-16 11:10:40

事实证明,处理私有索引的正确方法是使用 extra-index-url开关。从documentation of pip

Note that using index-url removes the use of PyPI, while using extra-index-url will add additional indexes.

所以,放线

 extra-index-url https://testpypi.python.org/pypi

再加上你的requirements.txt就足够了。根本不需要层叠!在

相关问题 更多 >