pip install via requests.txt 指定直接 GitHub 私有存储库 + 分支名称,错误退出状态 128

Int*_*rer 11 python git pip github requirements.txt

我正在尝试将一个包添加到我的requirements.txt文件中,即:

  • 来自私人 GitHub 存储库
    • 我是私人回购的成员
    • 我已经ssh配置了私人仓库
  • 来自 之外的一个分支master,其名称中带有斜杠
  • 使用ssh协议

互联网上到处都是关于这个话题的问题。以下是关于此的pip文档

pip install -e "vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir"

以及来自如何在requirements.txt中声明直接github源的GitHub答案

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


尝试方法#1

我试图在我的requirements.txt文件中使用这个答案:

-e git+ssh://github.com/Organization/repo-name.git@branch/name#egg=foo
Run Code Online (Sandbox Code Playgroud)

我收到错误:

ERROR: Command errored out with exit status 128: git clone -q ssh://github.com/Organization/repo-name.git /path/to/venv/src/foo Check the logs for full command output.
Run Code Online (Sandbox Code Playgroud)

当我使用以下选项查看日志时--log

-e git+ssh://github.com/Organization/repo-name.git@branch/name#egg=foo
Run Code Online (Sandbox Code Playgroud)

尝试方法#2

我尝试的另一种方法requirements.txt

-e git+git@github.com:Organization/repo-name.git#egg=foo
Run Code Online (Sandbox Code Playgroud)

这里面的克隆确实有效!它还打印此警告:DEPRECATION: This form of VCS requirement is being deprecated

不幸的是,我无法弄清楚如何以这种格式指定分支名称。


我究竟做错了什么?我错过了什么吗?

仅供参考,我的版本:

ERROR: Command errored out with exit status 128: git clone -q ssh://github.com/Organization/repo-name.git /path/to/venv/src/foo Check the logs for full command output.
Run Code Online (Sandbox Code Playgroud)

Int*_*rer 12

我在这两种情况下都解决了我的问题......语法


尝试#1

错误:需要说git@github.com

正确方法:

-e git+ssh://git@github.com/Organization/repo-name.git@branch/name#egg=foo
Run Code Online (Sandbox Code Playgroud)

尝试#2

错误:不知道可以使用@两次

正确方法:

-e git+git@github.com:Organization/repo-name.git@branch/name#egg=foo
Run Code Online (Sandbox Code Playgroud)

  • “-e”对于我的版本(pip 9.0.1 和 git 版本 2.17.1)是可选的:没有它,包将安装到站点包中。用户可能更喜欢其中之一。 (2认同)