从git repo分支安装pip

尝试pip安装存储库的特定分支。谷歌告诉我

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。

如何安装此分支?

694419 次浏览

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

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

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

使用带有git+的pip来克隆存储库可能非常慢(例如使用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和尾随#egg=blah-blah是必需的没有,您只需粘贴URL即可,因此您的requirements.txt如下所示:

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

只是为了添加一个额外的,如果你想在你的pip文件中安装它,可以这样添加:

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

它将被保存为一个鸡蛋。

使用ssh凭据从私有存储库安装的说明:

$ 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/

您使用了鸡蛋文件安装过程。此过程支持安装超过gitgit+httpgit+httpsgit+sshgit+gitgit+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

这是一种非常新的格式,比鸡蛋文件更新。它需要轮子和setupols>=0.8包。您可以在这里中找到更多。

这就像魅力一样:

pip3 install git+https://github.com/deepak1725/fabric8-analytics-worker.git@develop

在哪里:

开发:

fabric8-analytics-worker.git:回购

Deepak1725:用户

对于windows和pycharm设置:

如果您使用化脓和如果您想使用pip3 install git+https://github.com/...

输入图片描述

对我你的建议从问题工作。

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@devCollecting git+https://github.com/moskomule/anatome.git@devCloning https://github.com/moskomule/anatome.git (to revision dev) to /private/var/folders/x4/0xq0brj57xz3dbhbmblypbm00000gr/T/pip-req-build-62d_ghd2Running command git clone -q https://github.com/moskomule/anatome.git /private/var/folders/x4/0xq0brj57xz3dbhbmblypbm00000gr/T/pip-req-build-62d_ghd2Running command git checkout -b dev --track origin/devSwitched 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 4b576e51cb1824a57ea04974e0f92b5a6143294dRequirement 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: anatomeBuilding wheel for anatome (setup.py) ... doneCreated wheel for anatome: filename=anatome-0.0.6-py3-none-any.whl size=10167 sha256=63b12a36f33deb8313bfe7756be60bd08915b8ba36711be47e292b590df70f61Stored in directory: /private/var/folders/x4/0xq0brj57xz3dbhbmblypbm00000gr/T/pip-ephem-wheel-cache-rde_ngug/wheels/19/e4/be/01479e8cba62ae8cdcd501cd3bf49e199f2bb94732a6a1b006Successfully built anatomeInstalling collected packages: anatomeAttempting uninstall: anatomeFound existing installation: anatome 0.0.5Uninstalling anatome-0.0.5:Successfully uninstalled anatome-0.0.5Successfully installed anatome-0.0.6

0.6.0是开发分支版本号,0.5.0是主版本号,所以它起作用了!