试图pip安装一个回购的特定分支。谷歌告诉我

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

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

如何安装这个分支?


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

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

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


使用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

for Django stable/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

在这里,主分支通常被命名为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/


您使用了egg文件安装过程。 此过程支持通过git、git+http、git+https、git+ssh、git+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

这是很新的格式,比鸡蛋文件更新。它需要wheel和setuptools>=0.8个包。您可以在文档中找到更多信息。


这招很管用:

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

地点:

发展:分支

fabric8-analytics-worker。git:回购

deepak1725:用户


对于windows和pycharm设置:

如果你正在使用pycharm和如果你想使用pip3安装git+https://github.com/…

首先,你应该从https://git-scm.com/downloads下载git 然后重新启动pycharm 你可以使用pycharm终端来安装你想要的


你从问题工作中给我的建议是什么?

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是主版本号,所以它可以工作!