Pip is a package manager of python. You can download Python libraries from some Python repositories like PyPI
. You can also download libraries from a git
repository. This is gonna be the issue to be explained in this article.
As you may know, you can use two protocols which are http
and ssh
to do something on git
repositories. Using protocol ssh
instead of http
may provide some ease of use. Because of nature of ssh
, you can do something with your primary/public keys. So, you don't have to input your credentials all the time. But I'll be giving a way for both;
Here are the example with Github
repositories;
For HTTP
pip install git+https://github.com/<project_owner>/<project_name>
For SSH
pip install git+ssh://git@github.com/<project_owner>/<project_name>.git
For Local Git Repository
pip install git+file///path/to/your/git/project/
Installing a special branch, tag or commit
The above commands will only install what is available in the default branch. In most of the cases you want to target a specific branch, tag or maybe even a commit. This can be achieved by providing @
argument to the git string.
Example:
pip install git+https://github.com/nezhar/django-model-prefix@a5cabf1ac210b6358ea358b1d268d802114d85d4
Providing options for extras_require
Some packages provide extras_require
inside setup.py
or setup.cfg
. In order to target them during the installation process, the #egg
argument must be provided as a value in contains the name of the package and the option for the extras_require
.
Example:
pip install git+https://github.com/anexia-it/jsonschema@draft2020-12#egg=jsonschema[format]
pip install https://github.com/user/repo.git@branch
doingpip install -U git+https://github.com/moskomule/anatome.git@dev
worked. Perhaps remove the extra/
?