gpt4 book ai didi

python - 如何在 requirements.txt 中声明一个直接的 github 源

转载 作者:IT老高 更新时间:2023-10-28 12:05:45 29 4
gpt4 key购买 nike

我已经使用命令安装了一个库

pip install git+git://github.com/mozilla/elasticutils.git

直接从 Github 存储库安装它。这很好用,我想在我的 requirements.txt 中拥有这种依赖关系。我看过其他票,例如 this但这并没有解决我的问题。如果我放类似

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

documentation of the requirements file没有提到使用 git+git 协议(protocol)说明符的链接,所以可能只是不支持。

有人能解决我的问题吗?

最佳答案

通常您的 requirements.txt 文件看起来像这样:

package-one==1.9.4
package-two==3.7.1
package-three==1.0.1
...

要指定 Github 存储库,您不需要 package-name== 约定。

以下示例使用 GitHub 存储库更新 package-two@# 之间的文本表示包的细节。

指定提交哈希(41b95ec 在更新的 requirements.txt 的上下文中):

package-one==1.9.4
git+https://github.com/path/to/package-two@41b95ec#egg=package-two
package-three==1.0.1

指定分支名称(master):

git+https://github.com/path/to/package-two@master#egg=package-two

指定标签(0.1):

git+https://github.com/path/to/package-two@0.1#egg=package-two

指定版本(3.7.1):

git+https://github.com/path/to/package-two@releases/tag/v3.7.1#egg=package-two

注意#egg=package-two这里不是注释,是给explicitly state the package name

This blog post有更多关于该主题的讨论。

关于python - 如何在 requirements.txt 中声明一个直接的 github 源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16584552/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com