Python pip 安装本地 git 仓库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14159482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip install a local git repository
提问by Fábio Santos
I can't find the correct way to install a local directory as a python package using pip.
我找不到使用 pip 将本地目录安装为 python 包的正确方法。
(venv) C:\(...)>pip install . --no-index
Ignoring indexes: http://pypi.python.org/simple/
Unpacking c:\users\fsantos\desktop\biskates.com\biskates\forks\django-pipeline
Running setup.py egg_info for package from file:///(...)%5Cforks%5Cdjango-pipeline
Installing collected packages: django-pipeline
Running setup.py install for django-pipeline
Successfully installed django-pipeline
Cleaning up...
(venv) C:\(...)>cd ..
(venv) C:\(...)>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pipeline
>>> pipeline.__file__
'C:\(...)site-packages\pipeline\__init__.py'
>>>
As you can see pip just copied over the package to site-packages. How can I avoid this, and use the package directly from its source folder?
如您所见,pip 刚刚将包复制到站点包。如何避免这种情况,并直接从其源文件夹中使用该包?
I'm trying to integrate django-pipeline into my Django project, but I want to add support for Django 1.4 first, so I forked and cloned my fork.
我正在尝试将 django-pipeline 集成到我的 Django 项目中,但我想首先添加对 Django 1.4 的支持,所以我分叉并克隆了我的分叉。
采纳答案by silviomoreto
I can also just use:
我也可以只使用:
cd your-local-repo
pip install -e .
or
或者
python setup.py install develop
回答by Quilt
If you're working in a venv, you can do this:
如果你在 a 工作venv,你可以这样做:
env/bin/pip install git+file:///path/to/your/git/repo
Or with a branch:
或者有一个分支:
env/bin/pip install git+file:///path/to/your/git/repo@mybranch
回答by Danil
You can use pipor pipenvwith the following command to install from a local git repo:
您可以通过以下命令使用pip或pipenv从本地 git 存储库进行安装:
pip install git+file:///path/to/your/package#egg=package-name
Note that there are 3 slashes after file: here.
请注意,file: here 后面有 3 个斜杠。
To install from a remote repo use:
要从远程仓库安装,请使用:
pip install git+ssh://[email protected]:Username/Project.git
You can also specify a desired branch like so:
您还可以像这样指定所需的分支:
pip install git+ssh://[email protected]:Username/Project.git@master
I just rounded up the previous answers and comments from Quiltand nanounanueand this question. Also posted it here.
我刚刚收集了Quilt和nanounanue以及这个问题的先前答案和评论。也贴在这里。

