如何使用'pip'从github链接安装extrarequires`

2024-04-24 22:21:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我将这个python包放在github存储库中。我可以直接从github链接安装它,如下所示:

pip install git+https://github.com/mkdocs/mkdocs.git

我也希望这样做,但是安装一些额外的依赖项。仅使用包名时,我们可以执行以下操作:

pip install mkdocs[i18n]

但如果我尝试:

pip install git+https://github.com/mkdocs/mkdocs.git[i18n]

它失败,出现以下错误:

Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com

Collecting git+https://github.com/mkdocs/mkdocs.git[i18n]
Cloning https://github.com/mkdocs/mkdocs.git[i18n] to /tmp/pip-req-build-1ykhyonq
Running command git clone -q 'https://github.com/mkdocs/mkdocs.git[i18n]' /tmp/pip-req-build-1ykhyonq
fatal: unable to access 'https://github.com/mkdocs/mkdocs.git[i18n]/': The requested URL returned error: 400

WARNING: Discarding git+https://github.com/mkdocs/mkdocs.git[i18n]. Command errored out with exit status 128: git clone -q 'https://github.com/mkdocs/mkdocs.git[i18n]' /tmp/pip-req-build-1ykhyonq Check the logs for full command output.

ERROR: Command errored out with exit status 128: git clone -q 'https://github.com/mkdocs/mkdocs.git[i18n]' /tmp/pip-req-build-1ykhyonq Check the logs for full command output.


如何使用github链接的额外依赖项?


Tags: installpiphttpsgitbuildgithubpypicom
2条回答

这项工作:

pip install "git+https://github.com/mkdocs/mkdocs#egg=mkdocs[i18n]"

添加了#egg=mkdocs

下面是来自https://pip.pypa.io/en/stable/cli/pip_install/#examples的示例7:

pip install "mkdocs[i18n] @ git+https://github.com/mkdocs/mkdocs.git"

“@”符号的用法在PEP 440的direct references部分中有详细说明

相关问题 更多 >