对于相同的远程URL,“ git clone ...”有效,但“ pip install ...”无效

Cyg*_*985 4 python git ssh pip pipenv

我想通过Pipenv或pip + virtualenv从私有的,通过ssh访问的远程存储库中安装软件包。克隆有效时:

git clone git@remoteurl:username/package.git
Run Code Online (Sandbox Code Playgroud)

直接安装不会:

pip install git+ssh://git@remoteurl:username/package.git
Run Code Online (Sandbox Code Playgroud)

并输出以下错误:

ssh: Could not resolve hostname remoteurl:username: Name or service not known
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

我尝试了pip + virtualenv和pipenv,但均无效。我还尝试了以下几种url变体:

pip install git@remoteurl:username/package.git

pip install git+git@remoteurl:username/package.git

pip install git+remoteurl:username/package.git

pip install git+ssh://remoteurl:username/package.git
Run Code Online (Sandbox Code Playgroud)

它们都产生与上面给出的相同的错误。我在这里做错了什么?

Vla*_*eev 5

ssh:// git @ remoteurl:用户名/package.git

这是那种URL的错误语法。

Git理解SSH URL的两种语法:

  • user@host:path/to/repo.git
  • ssh://user@host/path/to/repo.git

因此,请尝试:

$ pip install git+ssh://git@remoteurl/username/package.git
Run Code Online (Sandbox Code Playgroud)

  • 感谢您的回答,现在可以了!对于其他人想知道有什么区别,因为我必须阅读您的链接 3 次,直到我发现,第二个“:”被替换为“/”。 (3认同)