Using pip and requirements.txt to install from the HEAD of a Github branch


The python package installer pip can be used to install directly from Github, like so:

$ pip install git+git://

This will install from the HEAD of the master branch. However, when you use pip freeze to export your dependencies (usually to a requirements.txt file), pip will fix the reference to a specific commit by including its ID within the URL:

$ pip freeze | grep oscar
-e git://

Hence running pip install -r requirements.txt will not pick any commits after d636b803 until requirements.txt is updated.

This isn’t always the desired behaviour; in some circumstances, you would prefer for pip install -r requirements.txt to always install the latest version from Github.


Simply delete the commit ID from URL - that is, change:

-e git://


-e git://

This can be done by hand once you’ve used

pip freeze > requirements.txt

to create your requirements file, or by using sed:

$ pip freeze | sed 's/@[a-z0-9]\+//' > requirements.txt


The text between @ and # in the github URL specifies the commit to install from. Rather than a commit ID, a branch or tag name can be used also. Hence:

pip install -e git://

will install the 0.1 tag, while:

pip install -e git://

will install from the HEAD of the releases/0.1 branch.

For further information, consult the requirements file format documentation.


Something wrong? Suggest an improvement or add a comment (see article history)
Tagged with: python
Filed in: tips

Previous: Console logging to STDOUT in Django
Next: How to set-up MySQL for Python on Ubuntu

Copyright © 2005-2017 David Winterbottom
Content licensed under CC BY-NC-SA 4.0.