如何在requirements.txt中声明一个直接的github源文件
我已经使用该命令安装了一个库
pip install git+git://github.com/mozilla/elasticutils.git  它直接从Github仓库安装它。 这工作正常,我想在我的requirements.txt有依赖。 我看过这样的其他门票,但这并没有解决我的问题。 如果我把类似的东西 
 -f git+git://github.com/mozilla/elasticutils.git elasticutils==0.7.dev 
 在requirements.txt文件中, pip install -r requirements.txt导致以下输出: 
 Downloading/unpacking elasticutils==0.7.dev (from -r requirements.txt (line 20)) Could not find a version that satisfies the requirement elasticutils==0.7.dev (from -r requirements.txt (line 20)) (from versions: ) No distributions matching the version for elasticutils==0.7.dev (from -r requirements.txt (line 20)) 
  需求文件的文档没有提到使用git+git协议说明符的链接,所以也许这只是不被支持。 
有没有人有我的问题的解决scheme?
 可以在requirements.txt使用“可编辑”包语法来从各种VCS(git,hg,bzr,svn)导入包: 
 -e git://github.com/mozilla/elasticutils.git#egg=elasticutils 
另外,可以指向特定的提交:
 -e git://github.com/mozilla/elasticutils.git@000b14389171a9f0d7d713466b32bc649b0bed8e#egg=elasticutils 
  requirements.txt允许以下方式从pip 7.0: 1开始,在git仓库中指定一个包的依赖关系 
 [-e] git+git://git.myproject.org/SomeProject#egg=SomeProject [-e] git+https://git.myproject.org/SomeProject#egg=SomeProject [-e] git+ssh://git.myproject.org/SomeProject#egg=SomeProject -e git+git@git.myproject.org:SomeProject#egg=SomeProject 
 对于Github,这意味着你可以做(注意省略-e ): 
 git+git://github.com/mozilla/elasticutils.git#egg=elasticutils 
  为什么要额外的答案? 
 在其他答案中,我被-e标志弄糊涂了,所以这是我的澄清: 
  -e或--editable标志表示软件包安装在<venv path>/src/SomeProject ,因此不在深埋的<venv path>/lib/pythonX.X/site-packages/SomeProject中放入。2 
文档
 通常你的requirements.txt文件看起来像这样: 
 package-one==1.9.4 package-two==3.7.1 package-three==1.0.1 ... 
 要指定一个Github仓库,你不需要package-name==约定。 
 下面的例子使用GitHub仓库更新了package-two 。  @和#之间的文本表示包的细节。 
 指定提交散列(在更新的requirements.txt的上下文中为41b95ec ): 
 package-one==1.9.4 git+git://github.com/path/to/package-two@41b95ec#egg=package-two package-three==1.0.1 
 指定分行名称( master ): 
 git+git://github.com/path/to/package-two@master#egg=package-two 
 指定标签( 0.1 ): 
 git+git://github.com/path/to/package-two@0.1#egg=package-two 
 指定发布( 3.7.1 ): 
 git+git://github.com/path/to/package-two@releases/3.7.1#egg=package-two 
 请注意#egg=package-two在这里不是注释,它是明确声明包名 
这篇博文有关于这个话题的更多讨论。
 首先,用git+git安装。 安装kronok的brabeion项目分支的brabeion : 
 pip install -e git+https://github.com/kronok/brabeion.git@12efe6aa06b85ae5ff725d3033e38f624e0a616f#egg=brabeion 
 其次,使用pip freeze > requirements.txt在你的requirements.txtfind正确的东西。 在这种情况下,你会得到 
 -e git+https://github.com/kronok/brabeion.git@12efe6aa06b85ae5ff725d3033e38f624e0a616f#egg=brabeion-master 
三,testing结果:
 pip uninstall brabeion pip install -r requirements.txt 
 自pip v1.5 (2014年1月1日发布: CHANGELOG , PR ) 以来 ,您也可以指定git repo的子目录来包含您的模块。 语法如下所示: 
 pip install -e git+https://git.repo/some_repo.git#egg=my_subdir_pkg&subdirectory=my_subdir_pkg # install a python package from a repo subdirectory 
注意:作为一个pip模块作者,理想情况下,如果可以的话,您可能希望将模块发布到自己的顶级回购站中。 然而,这个function对于一些在子目录中包含python模块的预先存在的仓库是有帮助的。 如果他们没有发布到pypi,你可能会被迫以这种方式安装它们。