PIP:如何级联需求文件并使用私有索引? [英] PIP: How to Cascade Requirements Files and Use Private Indexes?

查看:158
本文介绍了PIP:如何级联需求文件并使用私有索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我的设置看起来像这样。

 #requirements.txt 
-r要求/ req2.txt
-r要求/ 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 会导致以下错误。

 找不到满足要求的任何下载
Django == 1.7.7(from -r ./requirements/req2.txt(line 2))
Django找不到任何发行版== 1.7 .7
(from -r ./requirements/req2.txt(line 2))

所以对我来说看起来像设置 req3 中的 -i 参数,然后pip尝试在<$ c $上查找Django我尝试添加 -i https://pypi.python.org/pypi testpypi req2.txt 但我仍然得到相同的错误。 (可能 https://pypi.python.org/pypi 是错误的网址)



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

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



无可否认这个问题这一个非常相似,但都没有处理私有索引

解决方案

处理私有索引的正确方法是使用 - extra-index-url 开关。从点的文档


请注意,使用--index-url将删除PyPI的使用,而使用--extra-index-url将添加其他索引。


所以,把这一行放到

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

位于您的 requirements.txt 应该足够了。根本不需要级联!


I am trying to deploy a Django app to Heroku where one of the required packages lives on https://testpypi.python.org/pypi and of course Django is on the main PyPI server.

My setup looks like this.

# 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

Running the command: pip install -r requirements.txt results in the following error.

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))

So to me it looks like the -i argument in req3 is being set then pip tries to look for Django on the testpypi server.

I tried adding -i https://pypi.python.org/pypi to req2.txt but I still get the same error. (perhaps https://pypi.python.org/pypi is the wrong url)

In addition if I run either req*.txt file individually the installation of the package is successful?

How can one cascade requirements files and use private indexes?

Admittedly this question and this one are quite similar but neither deal with private indexs

解决方案

It turns out that the correct method of dealing with private indexes is to use --extra-index-url switch. From the documentation of pip:

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

So, putting the line

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

on top of your requirements.txt should be enough. No need to cascade at all!

这篇关于PIP:如何级联需求文件并使用私有索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆