pip安装远程代码仓库

pip 可以直接从 GitHub 仓库安装 Python 包。通过这种方式,你不仅可以安装发布版,还可以安装特定的分支、标签或提交版本。

使用 pip 从 GitHub 仓库安装 Python 包的基本命令格式如下:

1
pip install git+https://github.com/<username>/<repository>.git

你还可以通过在 URL 的末尾添加 @<ref> 来指定要安装的分支、标签或提交哈希。例如:

  • 安装特定的标签版本:

    1
    pip install git+https://github.com/<username>/<repository>.git@<tag>
  • 安装特定的分支:

    1
    pip install git+https://github.com/<username>/<repository>.git@<branch>
  • 安装特定的提交:

    1
    pip install git+https://github.com/<username>/<repository>.git@<commit>

例如,要安装 black 的 22.8.0 版本,可以使用以下命令:

1
pip install git+https://github.com/psf/black@22.8.0

这个命令会从 black 的 GitHub 仓库中安装 22.8.0 版本。


pip安装远程代码仓库
https://abrance.github.io/2025/02/12/mdstorage/domain/python/pip安装远程代码仓库/
Author
xiaoy
Posted on
February 12, 2025
Licensed under