4

我想通过 pipenv 或 pip + virtualenv 从一个私有的、ssh 访问的远程存储库安装一个包。克隆工作时:

git clone git@remoteurl:username/package.git

直接安装不会:

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

并输出以下错误:

ssh: Could not resolve hostname remoteurl:username: Name or service not known
fatal: Could not read from remote repository.

我试过 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

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

4

1 回答 1

8

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
于 2018-02-08T15:47:58.827 回答