moments now supports Python 3. Because Python is soon discontinuing support for Python 2, we do not actively ensure that moments remains fully compatable with Python 2, and strongly recommend using Python 3.

Using conda

moments is available via Bioconda.

The most recent release of moments can be installed by running

conda install -c bioconda moments

The conda channels must be set up to include bioconda, which can be done by running

conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge

Using pip

A simple way to install moments is via pip. numpy, mpmath, and cython are install requirements, but installing moments directly from the git repository using pip should install these dependencies automatically:

pip install git+

Alternatively, you can clone the git repository

git clone

and then from within the moments directory (cd moments), run

pip install -r requirements.txt
pip install .

Dependencies and details

moments and moments.LD requires a number of dependencies. Minimally, these include

  • numpy

  • scipy

  • cython

  • mpmath

Dependencies can be installed using pip. For example to install cython, run pip install cython. All the dependencies can be installed together using

pip install -r requirements.txt

Depending on the python distribution you use, it may be useful to add the directory to cython in your python path.

We also strongly recommend installing ipython for interactive analyses.

If you are using conda, all dependencies can be installed by navigating to the moments directory and then running

conda install --file requirements.txt

Once dependencies are installed, to install moments, run the following commands in the moments directory:

python build_ext --inplace
python install

Note that you might need sudo privileges to install in this way.

You should then be able to import moments in your python scripts. Entering an ipython or python session, type import moments. If, for any reason, you have trouble installing moments after following these steps, please submit an Issue.

If you use Parsing from moments.LD, which reads VCF-formatted files and computes LD statistics to compare to predictions from moments.LD, you will need to additionally install

  • hdf5

  • scikit-allel