亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 pip 從 git 安裝包到 site-packages

使用 pip 從 git 安裝包到 site-packages

慕仙森 2023-08-08 17:33:37
我使用 git 中的 pip 安裝了一個 Python 包。為了實現這一目標,我將該命令添加 -e git+<link>#<egg>到我的requirements.txt 中。Pip 安裝了這個包,但不是以我想要的方式安裝。第一個問題:我使用虛擬環境。通常,包最終以<env>/Lib/site-packages. 這一個沒有,它最終以<env>/src. 這使得進口變得更加困難。第二個問題:該src文件夾也是在我正在處理的實際項目中創建的。這兩件事都與從 PyPI 等其他來源安裝包不同。有沒有辦法以同樣的方式通過 git 安裝我自己的軟件包?我實際上構建了一個輪子和一個 tar.gz,但我不知道如何安裝它們......
查看完整描述

2 回答

?
白板的微信

TA貢獻1883條經驗 獲得超3個贊

-e選項使安裝的包可編輯,這不是我想要的。事實上,沒有它它也能工作!因此,如果您想避免src到處出現文件夾 - 從 git 下載而不帶 -e 選項: git+<link>#<egg>

不幸的是,我沒有找到任何這方面的文檔......所以請隨意發布更深刻的答案或添加到這個答案中。


查看完整回答
反對 回復 2023-08-08
?
Smart貓小萌

TA貢獻1911條經驗 獲得超7個贊

在requirements.txt中指定git+https位置的以下格式對我有用:


pycocotools@git+https://github.com/gautamchitnis/cocoapi.git@cocodataset-master#subdirectory=PythonAPI

但我必須先安裝numpyand Cython,這樣該包的安裝才能成功。setuptools已經安裝了,這可能也需要注意。


PS C:\Users\user\Documents\project> pip install -r requirements.txt

Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com, https://download.pytorch.org/whl/cu113

Collecting pycocotools@ git+https://github.com/gautamchitnis/cocoapi.git@cocodataset-master#subdirectory=PythonAPI

  Cloning https://github.com/gautamchitnis/cocoapi.git (to revision cocodataset-master) to c:\users\user\appdata\local\temp\pip-install-ofosrylu\pycocotools_6c865fdd5be947bdaed6b1bb6e7ec022

  Running command git clone -q https://github.com/gautamchitnis/cocoapi.git 'C:\Users\user\AppData\Local\Temp\pip-install-ofosrylu\pycocotools_6c865fdd5be947bdaed6b1bb6e7ec022'

  Running command git checkout -b cocodataset-master --track origin/cocodataset-master

  Branch 'cocodataset-master' set up to track remote branch 'cocodataset-master' from 'origin'.

  Switched to a new branch 'cocodataset-master'

# ... output of other packages

Building wheels for collected packages: pycocotools

  Building wheel for pycocotools (setup.py) ... done

  Created wheel for pycocotools: filename=pycocotools-2.0-cp39-cp39-win_amd64.whl size=82226 sha256=4fcb72a83132367541d71faa8f0fb5a838e910c017f9aa033d13c19aebaada61

  Stored in directory: C:\Users\user\AppData\Local\Temp\pip-ephem-wheel-cache-_ygd_748\wheels\a6\5f\ec\1eaf8c69abab5724baee819736e6d30adad774deb60736413b

Successfully built pycocotools


查看完整回答
反對 回復 2023-08-08
  • 2 回答
  • 0 關注
  • 238 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號