从git repo分支安装pip

chhkpiq4  于 2023-01-24  发布在  Git
关注(0)|答案(8)|浏览(166)

尝试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。
如何安装此分支?

uurity8g

uurity8g1#

预先添加URL前缀git+(请参见VCS Support):

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

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

dl5txlt9

dl5txlt92#

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

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

对Django主人来说变成了

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
polhcujo

polhcujo3#

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

qxgroojn

qxgroojn4#

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

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

它将被保存为一个鸡蛋虽然。

xlpyo6sf

xlpyo6sf5#

这很有魅力:

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

其中:
开发:分支
fabric8-分析-工作者. git:* * 回购协议**
deepak1725:用户

xhv8bpkk

xhv8bpkk6#

您使用了egg文件安装过程。此过程支持在gitgit+httpgit+httpsgit+sshgit+gitgit+file上安装。其中一些在其他答案中提到。
很好,你可以使用分支,标签,或者散列来安装。
Steve_K noted使用“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包。你可以在the documentation中找到更多。

8wigbo56

8wigbo567#

你从问题工作中提出的建议。

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

wsxa1bj1

wsxa1bj18#

对于windows和pycharm安装:
如果您正在使用pycharm和如果您要使用pip3 install git+https://github.com/...

相关问题