python – How to state in requirements.txt a direct github source

The Question :

502 people think this question is useful

I’ve installed a library using the command

pip install git+git://

which installs it directly from a Github repository. This works fine and I want to have that dependency in my requirements.txt. I’ve looked at other tickets like this but that didn’t solve my problem. If I put something like

-f git+git://

in the requirements.txt file, a pip install -r requirements.txt results in the following output:

Downloading/unpacking (from -r requirements.txt (line 20))
  Could not find a version that satisfies the requirement (from -r requirements.txt (line 20)) (from versions: )
No distributions matching the version for (from -r requirements.txt (line 20))

The documentation of the requirements file does not mention links using the git+git protocol specifier, so maybe this is just not supported.

Does anybody have a solution for my problem?

The Question Comments :

The Answer 1

363 people think this answer is useful

“Editable” packages syntax can be used in requirements.txt to import packages from a variety of VCS (git, hg, bzr, svn):

-e git://

Also, it is possible to point to particular commit:

-e git://

The Answer 2

511 people think this answer is useful

Normally your requirements.txt file would look something like this:


To specify a Github repo, you do not need the package-name== convention.

The examples below update package-two using a GitHub repo. The text between @ and # denotes the specifics of the package.

Specify commit hash (41b95ec in the context of updated requirements.txt):


Specify branch name (master):


Specify tag (0.1):


Specify release (3.7.1):


Note that #egg=package-two is not a comment here, it is to explicitly state the package name

This blog post has some more discussion on the topic.

The Answer 3

188 people think this answer is useful

requirements.txt allows the following ways of specifying a dependency on a package in a git repository as of pip 7.0:1

[-e] git+git://
[-e] git+
[-e] git+ssh://
-e (deprecated as of Jan 2020)

For Github that means you can do (notice the omitted -e):


Why the extra answer?
I got somewhat confused by the -e flag in the other answers so here’s my clarification:

The -e or --editable flag means that the package is installed in <venv path>/src/SomeProject and thus not in the deeply buried <venv path>/lib/pythonX.X/site-packages/SomeProject it would otherwise be placed in.2


The Answer 4

87 people think this answer is useful

First, install with git+git or git+https, in any way you know. Example of installing kronok‘s branch of the brabeion project:

pip install -e git+

Second, use pip freeze > requirements.txt to get the right thing in your requirements.txt. In this case, you will get

-e git+

Third, test the result:

pip uninstall brabeion
pip install -r requirements.txt

The Answer 5

18 people think this answer is useful

Since pip v1.5, (released Jan 1 2014: CHANGELOG, PR) you may also specify a subdirectory of a git repo to contain your module. The syntax looks like this:

pip install -e git+https://git.repo/some_repo.git#egg=my_subdir_pkg&amp;subdirectory=my_subdir_pkg # install a python package from a repo subdirectory

Note: As a pip module author, ideally you’d probably want to publish your module in it’s own top-level repo if you can. Yet this feature is helpful for some pre-existing repos that contain python modules in subdirectories. You might be forced to install them this way if they are not published to pypi too.

The Answer 6

3 people think this answer is useful

Github has a zip endpoint that in my opinion is preferable to using the git protocol. The advantages are:

  • You don’t have to specify #egg=<project name>
  • Git doesn’t need to be installed in your environment, which is nice for containerized environments
  • It works much better with pip hashing
  • The URL structure is easier to remember and more discoverable

You usually want requirements.txt entries to look like this, e.g. without the -e prefix:

To install from main branch:

The Answer 7

2 people think this answer is useful

I’m finding that it’s kind of tricky to get pip3 (v9.0.1, as installed by Ubuntu 18.04’s package manager) to actually install the thing I tell it to install. I’m posting this answer to save anyone’s time who runs into this problem.

Putting this into a requirements.txt file failed:


By “failed” I mean that while it downloaded the code from Git, it ended up installing the original version of the code, as found on PyPi, instead of the code in the repo on that branch.

However, installing the commmit instead of the branch name works:


Add a Comment