从 git repo 分支安装 pip

2024-12-03 08:44:00
admin
原创
163
摘要:问题描述:尝试pip安装 repo 的特定分支。Google 告诉我pip install https://github.com/user/repo.git@branch 分支的名称是issue/34/oscar-0.6我所做的pip install https://github.com/tangentlab...

问题描述:

尝试pip安装 repo 的特定分支。Google 告诉我

pip install https://github.com/user/repo.git@branch

分支的名称是issue/34/oscar-0.6我所做的pip install https://github.com/tangentlabs/django-oscar-paypal.git@/issue/34/oscar-0.6,但它返回 404。

我该如何安装这个分支?


解决方案 1:

添加 url 前缀git+(参见VCS 支持):

pip install git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6

并指定不带前导 的分支名称/

解决方案 2:

使用 pip 和 git+ 克隆存储库可能会非常慢(例如,使用https://github.com/django/django@stable/1.6.x进行测试,需要几分钟)。我发现最快的方法是与 GitHub 和 BitBucket 配合使用:

pip install https://github.com/user/repository/archive/branch.zip

对于 Django master 来说:

pip install https://github.com/django/django/archive/master.zip

对于 Django 稳定版/1.7.x:

pip install https://github.com/django/django/archive/stable/1.7.x.zip

对于 BitBucket 来说,它有着大致相同的可预测模式:

pip install https://bitbucket.org/izi/django-admin-tools/get/default.zip

这里,master 分支一般被命名为 default。这将使你的requirements.txt安装速度更快。

其他一些答案提到了将要安装的包放入时所需的变化。请注意,使用此存档语法,不需要requirements.txt前导-e和尾随,您只需粘贴 URL 即可,因此您的 requirements.txt 如下所示:#egg=blah-blah

https://github.com/user/repository/archive/branch.zip

解决方案 3:

使用ssh 凭证从私有 repo 安装的说明:

$ pip install git+ssh://git@github.com/myuser/foo.git@my_version

要从子目录安装包,例如stackoverflow

$ pip install git+ssh://git@github.com/myuser/foo.git@my_version#subdirectory=stackoverflow

https://pip.pypa.io/en/stable/topics/vcs-support/

解决方案 4:

这很有效果:

pip3 install git+https://github.com/user/repo.git@develop
场地价值
协议https
用户user
存储库repo
分支develop

这是一个具体的例子:pip3 install git+https://github.com/deepak1725/fabric8-analytics-worker.git@develop

解决方案 5:

只需添加一个额外内容,如果您想将其安装在您的 pip 文件中,可以像这样添加:

-e git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6#egg=django-oscar-paypal

但它将被保存为一个鸡蛋。

解决方案 6:

您使用了 egg 文件安装程序。此过程支持git在 、git+httpgit+https、和上进行安装。其中一些在其他答案中提到过git+sshgit+git`git+file`

很好。您可以使用分支、标签或哈希来安装。

Steve_K 注意到使用“git+”安装可能会很慢,因此建议通过 zip 文件安装:

pip install https://github.com/user/repository/archive/branch.zip

或者,如果该文件存在,我建议您可以使用该.whl文件进行安装。

pip install https://github.com/user/repository/archive/branch.whl

它是一种相当新的格式,比 egg 文件更新。它需要wheelsetuptools>=0.8包。您可以在文档中找到更多信息。

解决方案 7:

对我来说你的建议来自问题工作例如

pip install https://github.com/user/repo.git@branch

具体转化为行动

pip install -U git+https://github.com/moskomule/anatome.git@dev

有效。也许删除多余的部分/是多余的。我的输出:

(original_anatome_env) brando~/ultimate-anatome ❯ pip install -U git+https://github.com/moskomule/anatome.git@dev
Collecting git+https://github.com/moskomule/anatome.git@dev
  Cloning https://github.com/moskomule/anatome.git (to revision dev) to /private/var/folders/x4/0xq0brj57xz3dbhbmblypbm00000gr/T/pip-req-build-62d_ghd2
  Running command git clone -q https://github.com/moskomule/anatome.git /private/var/folders/x4/0xq0brj57xz3dbhbmblypbm00000gr/T/pip-req-build-62d_ghd2
  Running command git checkout -b dev --track origin/dev
  Switched to a new branch 'dev'
  Branch 'dev' set up to track remote branch 'dev' from 'origin'.
  Resolved https://github.com/moskomule/anatome.git to commit 4b576e51cb1824a57ea04974e0f92b5a6143294d
Requirement already satisfied: torch>=1.10.0 in /Users/brando/anaconda3/envs/metalearning/envs/original_anatome_env/lib/python3.9/site-packages (from anatome==0.0.6) (1.10.0)
Requirement already satisfied: torchvision>=0.11.1 in /Users/brando/anaconda3/envs/metalearning/envs/original_anatome_env/lib/python3.9/site-packages (from anatome==0.0.6) (0.11.1)
Requirement already satisfied: typing-extensions in /Users/brando/anaconda3/envs/metalearning/envs/original_anatome_env/lib/python3.9/site-packages (from torch>=1.10.0->anatome==0.0.6) (3.10.0.2)
Requirement already satisfied: pillow!=8.3.0,>=5.3.0 in /Users/brando/anaconda3/envs/metalearning/envs/original_anatome_env/lib/python3.9/site-packages (from torchvision>=0.11.1->anatome==0.0.6) (8.4.0)
Requirement already satisfied: numpy in /Users/brando/anaconda3/envs/metalearning/envs/original_anatome_env/lib/python3.9/site-packages (from torchvision>=0.11.1->anatome==0.0.6) (1.21.4)
Building wheels for collected packages: anatome
  Building wheel for anatome (setup.py) ... done
  Created wheel for anatome: filename=anatome-0.0.6-py3-none-any.whl size=10167 sha256=63b12a36f33deb8313bfe7756be60bd08915b8ba36711be47e292b590df70f61
  Stored in directory: /private/var/folders/x4/0xq0brj57xz3dbhbmblypbm00000gr/T/pip-ephem-wheel-cache-rde_ngug/wheels/19/e4/be/01479e8cba62ae8cdcd501cd3bf49e199f2bb94732a6a1b006
Successfully built anatome
Installing collected packages: anatome
  Attempting uninstall: anatome
    Found existing installation: anatome 0.0.5
    Uninstalling anatome-0.0.5:
      Successfully uninstalled anatome-0.0.5
Successfully installed anatome-0.0.6

0.6.0 是开发分支版本号,0.5.0 是主版本,因此它成功了!

解决方案 8:

如果您需要在使用直接链接到 git 存储库时安装可选依赖项,请参考以下示例:

pip install "django[bcrypt] @ git+ssh://git@github.com/django/django.git"

解决方案 9:

对于 Windows 和 Pycharm 设置:

如果你正在使用pycharm并且想要使用pip3 install git+https://github.com/...

在此处输入图片描述

相关推荐
  政府信创国产化的10大政策解读一、信创国产化的背景与意义信创国产化,即信息技术应用创新国产化,是当前中国信息技术领域的一个重要发展方向。其核心在于通过自主研发和创新,实现信息技术应用的自主可控,减少对外部技术的依赖,并规避潜在的技术制裁和风险。随着全球信息技术竞争的加剧,以及某些国家对中国在科技领域的打压,信创国产化显...
工程项目管理   1565  
  为什么项目管理通常仍然耗时且低效?您是否还在反复更新电子表格、淹没在便利贴中并参加每周更新会议?这确实是耗费时间和精力。借助软件工具的帮助,您可以一目了然地全面了解您的项目。如今,国内外有足够多优秀的项目管理软件可以帮助您掌控每个项目。什么是项目管理软件?项目管理软件是广泛行业用于项目规划、资源分配和调度的软件。它使项...
项目管理软件   1354  
  信创国产芯片作为信息技术创新的核心领域,对于推动国家自主可控生态建设具有至关重要的意义。在全球科技竞争日益激烈的背景下,实现信息技术的自主可控,摆脱对国外技术的依赖,已成为保障国家信息安全和产业可持续发展的关键。国产芯片作为信创产业的基石,其发展水平直接影响着整个信创生态的构建与完善。通过不断提升国产芯片的技术实力、产...
国产信创系统   21  
  信创生态建设旨在实现信息技术领域的自主创新和安全可控,涵盖了从硬件到软件的全产业链。随着数字化转型的加速,信创生态建设的重要性日益凸显,它不仅关乎国家的信息安全,更是推动产业升级和经济高质量发展的关键力量。然而,在推进信创生态建设的过程中,面临着诸多复杂且严峻的挑战,需要深入剖析并寻找切实可行的解决方案。技术创新难题技...
信创操作系统   27  
  信创产业作为国家信息技术创新发展的重要领域,对于保障国家信息安全、推动产业升级具有关键意义。而国产芯片作为信创产业的核心基石,其研发进展备受关注。在信创国产芯片的研发征程中,面临着诸多复杂且艰巨的难点,这些难点犹如一道道关卡,阻碍着国产芯片的快速发展。然而,科研人员和相关企业并未退缩,积极探索并提出了一系列切实可行的解...
国产化替代产品目录   28  
热门文章
项目管理软件有哪些?
云禅道AD
禅道项目管理软件

云端的项目管理软件

尊享禅道项目软件收费版功能

无需维护,随时随地协同办公

内置subversion和git源码管理

每天备份,随时转为私有部署

免费试用