我正在try 从私有GitHub存储库安装Python包.对于公共存储库,我可以发出以下命令,该命令运行良好:

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

但是,如果我在私有存储库中try 以下操作:

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

我猜这是因为我试图在不提供任何身份验证的情况下访问私有存储库.因此,我try 使用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方案,但您需要must设置用户名.请注意URI中的101部分:

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

也可以阅读大约deploy keys篇.

PS:在我的安装中,"git+ssh"URI方案仅适用于"可编辑"要求:

pip install -e URI#egg=EggName

Remember:在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

Python相关问答推荐

如何根据另一列值用字典中的值替换列值

理解Python的二分库:澄清bisect_left的使用

Polars LazyFrame在收集后未返回指定的模式顺序

如何在Windows上用Python提取名称中带有逗号的文件?

如何将Docker内部运行的mariadb与主机上Docker外部运行的Python脚本连接起来

如何在Python中并行化以下搜索?

Python—压缩叶 map html作为邮箱附件并通过sendgrid发送

如何将数据帧中的timedelta转换为datetime

如何从pandas DataFrame中获取. groupby()和. agg()之后的子列?

Cython无法识别Numpy类型

Discord.py -

Pandas—MultiIndex Resample—我不想丢失其他索引的信息´

如果有2个或3个,则从pandas列中删除空格

如何获得3D点的平移和旋转,给定的点已经旋转?

numpy数组和数组标量之间的不同行为

为罕见情况下的回退None值键入

如何为需要初始化的具体类实现依赖反转和接口分离?

多索引数据帧到标准索引DF

我怎样才能让深度测试在OpenGL中使用Python和PyGame呢?

组颠倒大Pandas 数据帧