如何从GitHub或BitBucket安装一个私有软件包

866 阅读1分钟

在本教程中,你可以看到如何用pip从GitHub或BitBucket安装一个私有软件包。

从GitHub上安装一个私有包

要在GitHub上安装私有软件包,你需要使用以下语法。pip install git+repo:

例子为

pip install git+ssh://git@bitbucket.org/username/projectname.git

或以公共项目为例

pip install git+https://github.com/softhints/python.git

对于私有仓库,这将触发一个令牌提示或其他认证方法。

主机'github.com(ip)'的真实性无法建立

你可能还会面临这样的警告信息:

The authenticity of host 'github.com (ip)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?

你需要验证指纹--GitHub的SSH密钥指纹,如果匹配,你可以回答--是。

你可以找到GitHub上列出的所有公开测试:

  • SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 (RSA)

和相应的日期。

从BitBucket安装一个私有包

从BitBucket安装私有软件包,你可以使用下面的语法:

pip install git+ssh:repo

pip install git+ssh://git@bitbucket.org/username/projectname.git

Pip 在这种情况下,将尝试使用你的SSH密钥。如果缺少钥匙,你会被提示输入钥匙,否则你会得到一个错误。