Search code examples
pythongitsshpippipenv

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


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?


Solution

  • 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