Installing a Python package from Github

While the standard route for installing a Python package would be to upload the package to PyPI and then use pip, clearly some packages are too narrow in scope for this. For example, why should the rest of the world care about Python code for generating efficiency plots for SALT?

But still… using pip would be useful even for such packages, as you might need them in different locations. And you can.

To illustrate the process, we’ll create and “distribute” a very simple package, which is offering a function for displaying a Numpy vector of integers. Start by creating a parent folder, say MyApp/, and in there create a Python package saao_vector including a file with the following content.

import numpy as np

def display_vector():

The details required for installing this package must be included in a file, which should look like the following.

from setuptools import setup

readme = file('README.txt')
readme_text = ''
for line in readme:
    readme_text += line

      description='nonsensical vector package for testing',
      author='Christian Hettlage',

If we had a package a.b, you might have to include both 'a' and 'a.b' in the packages array. Note that we have defined NumPy as an installation requirement, which will make pip install it automatically.

The next step is to create a repository on Github and put the content of MyApp folder (but not the folder itself) there. should be at the top level of the repository.

With all this in place you can include the package in your project by adding its Github address to your projects requirements.txt file:


Note the git+https in the Github address line.

If you want to install from a local repository, you would use


When running pip with the requirements file

pip install -r requirements.txt

the package is installed along with NumPy.