1. Mike Hughes
  2. bnpy-dev


Clone wiki

bnpy-dev / Installation

This document should provide all the steps to get bnpy installed on your computer.


bnpy depends on Python and the following (external) Python packages


  • numpy (version 1.8 or later)
  • scipy

Optional for visualization

  • matplotlib

Optional for faster execution of learning algorithms

Installing a Python stack with all required modules

We highly recommend the Enthought Python distribution.

It's one-click install comes with all the requirements for bnpy and avoids the hassle of individually installing each package.

Furthermore, the numerical subroutines for matrix operations that ship with the EPD are almost always better than what a novice user can build themselves from source or have installed from other routes. We've routinely observed speedups of 2-4x on basic operations like matrix multiplication.

Alternate installation

The Anaconda distribution of Python will probably also be successful.

Finally, you can build the dependencies like numpy and scipy from source, or install via a package manager like "easy_install" or "pip". If you must go this route, we recommend using pip. You can search the web for the latest and greatest instructions for installing these. This route requires lots of manual effort and is only recommended as a last resort for experts.

Installing bnpy

You can grab the latest stable version from our active-development git repository, known as bnpy-dev.

Execute the following command to have the project file structure cloned to your local disk, within a folder called "bnpy-dev"

git clone https://michaelchughes@bitbucket.org/michaelchughes/bnpy-dev/

Make sure everything works!

Throughout all documentation, we'll call the directory where bnpy is installed $BNPYROOT. Wherever you see this, substitute in the actual directory on your system.

If you execute ls $BNPYROOT, you should see a README.md file and folders like "bnpy/", "datasets/", and more.

Verify numpy install

Open a terminal, and type python to drop into a python shell. Then type.

import numpy
print numpy.__version__

If you can do this without errors (and you have at least version 1.8), you are good to go!

Verify matplotlib install

Open a terminal, type python to drop into a python shell. Then type

from matplotlib import pylab

If that produces a figure with a simple line plot, you're good to go!

Common errors

If you try the above and get errors about not having "wx" or "wxpython" or "qt" installed, you need to configure your matplotlib backend.

See Matplotlib documentation for answers.

I recommend setting your matplotlibrc file to have backend: TkAgg for Linux, and backend: MacOSX for Mac.

Optional: Fast C++ libraries for HMM inference

By default, bnpy code will use normal Python code to do expensive dynamic programming required by the local step of HMM inference. However, you can speed this up by building a C++ library called libfwdbwd, as follows:

$ export EIGENPATH=/path/to/eigen3/
$ make libfwdbwd

This step requires two dependencies:

  • Gnu C++ compiler
    • If you can type which g++ at the terminal, you are good.
    • Windows users may experience bugs. Please submit error reports.
  • Eigen matrix library
    • Must be installed on your system in a location specified by EIGENPATH environment variable.

Once compiled via the make command, bnpy will automatically use the libfwdbwd C++ library instead of the pure Python versions of dynamic programming algorithms (see HMMUtil.py for details). Note that these have been designed to produce exactly the same output, so speed is the only difference.