'git clone …' works but not 'pip install …' for the same remote url

江枫思渺然 提交于 2019-12-07 08:10:40

问题


I want to install a package via pipenv or pip + virtualenv from a private, ssh accessed, remote repository. While cloning works:

git clone git@remoteurl:username/package.git

directly installing doesn't:

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

and outputs the following error:

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

I tried pip+virtualenv and pipenv, neither works. I also tried several variations of the url like the following:

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

all of them produce the same error given above. What am I doing wrong here?


回答1:


ssh://git@remoteurl:username/package.git

That's the wrong syntax for that kind of URLs.

Git understands two syntaxes of SSH URLs:

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

So, try:

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


来源:https://stackoverflow.com/questions/48689415/git-clone-works-but-not-pip-install-for-the-same-remote-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!