是否可以使用pip从私有github仓库安装一个包?

问题:

正如标题所示,我试图从私人github repo安装一个python包。对于公共存储库,我可以发出以下命令:

pip install git+git://github.com/django/django.git

但是,如果我尝试这个私人仓库:

pip install git+git://github.com/echweb/echweb-utils.git

我得到以下输出:

Downloading/unpacking git+git://github.com/echweb/echweb-utils.git
Cloning Git repository git://github.com/echweb/echweb-utils.git to /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build
Complete output from command /usr/local/bin/git clone git://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build:
fatal: The remote end hung up unexpectedly

Cloning into /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build...

----------------------------------------
Command /usr/local/bin/git clone git://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build failed with error code 128

我想这是因为我正在尝试访问私有存储库而不提供任何身份验证。因此,我试图使用git + ssh希望该pip将使用我的ssh公钥进行身份验证:

pip install git+ssh://github.com/echweb/echweb-utils.git

这给出以下输出:

Downloading/unpacking git+ssh://github.com/echweb/echweb-utils.git
Cloning Git repository ssh://github.com/echweb/echweb-utils.git to /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build
Complete output from command /usr/local/bin/git clone ssh://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build:
Cloning into /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build...

Permission denied (publickey).

fatal: The remote end hung up unexpectedly

----------------------------------------
Command /usr/local/bin/git clone ssh://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build failed with error code 128

有人知道我想要实现的是甚么可能吗?如果可以,请告诉我怎么样?

回答:

您可以使用git+ssh URI方案,但您必须设置用户名:

pip install git+ssh://git@github.com/echweb/echweb-utils.git

查看部分到URI?
PS:另请参阅deploy keys
PPS:在我的安装中,“git + ssh”URI方案仅适用于“可编辑”要求:

pip install -e URI#egg=EggName

 记得:在pip命令中使用遥控器的地址之前,将git remote -v打印的:字符更改为/字符:

$ git remote -v
origin  git@github.com:echweb/echweb-utils.git (fetch)
                      ^ change this to a '/' character

如果你忘了,你会得到这个错误:

ssh: Could not resolve hostname github.com:echweb:
         nodename nor servname provided, or not known

 
 
Code问答: http://codewenda.com/topics/python/
Stackoverflow: Is it possible to use pip to install a package from a private github repository?

*转载请注明本文链接以及stackoverflow的英文链接

发表评论

电子邮件地址不会被公开。 必填项已用*标注

41 + = 42