簡體   English   中英

從 git repo 分支安裝 pip

[英]pip install from git repo branch

嘗試pip安裝一個 repo 的特定分支。 谷歌告訴我

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。

我如何安裝這個分支?

預先添加 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 大師:

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

對於 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

在這里,master 分支一般被命名為 default。 這將使您的requirements.txt安裝速度更快。

其他一些答案提到了將要安裝的包放入您的requirements.txt 請注意,這個檔案的語法,領先-e和尾隨#egg=blah-blah不是必需的,你可以只是簡單粘貼URL,所以你requirements.txt的樣子:

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

使用ssh 憑據從私有倉庫安裝的說明:

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

只是添加一個額外的,如果你想將它安裝在你的 pip 文件中,它可以像這樣添加:

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

不過它會被保存為一個雞蛋。

這就像魅力一樣:

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

哪里:

開發:分支

fabric8-analytics-worker.git :回購

deepak1725:用戶

您使用了egg 文件安裝程序。 此過程支持通過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

這是一種非常新的格式,比egg 文件更新。 它需要wheel和setuptools>=0.8包。 您可以在此處找到更多信息

對於 Windows 和 pycharm 設置:

如果您正在使用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@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 是 dev 分支版本號,0.5.0 是 master,所以它有效!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM