This documentation is for astroML version 0.2

This page


astroML Mailing List

GitHub Issue Tracker


Scipy 2012 (15 minute talk)

Scipy 2013 (20 minute talk)


If you use the software, please consider citing astroML.

2. Installation of astroML

The astroML project is split into two components. The core astroML library is written in python only, and is designed to be very easy to install for any users, even those who don’t have a working C or fortran compiler. A companion library, astroML_addons, can be optionally installed for increased performance on certain algorithms. Every algorithm in astroML_addons exists in the core astroML implementation, but the astroML_addons library contains faster and more efficient implementations. Furthermore, if astroML_addons is installed on your system, the core astroML library will import and use the faster routines by default.

2.2. Installation

2.2.1. Python Package Index

The easiest way to install astroML is to use the Python Package Index pip command. First make sure the dependencies are fulfilled: lacking some of these may not affect installation, but it will affect the ability to execute code and examples. Next, use the pip command to install the packages:

pip install astroML
pip install astroML_addons

(For information about pip, see The first package is python-only, and should install easily on any system. The second package requires a working C compliler. astroML_addons provides optional faster implementations of some routines.

2.2.2. From Source

To install the latest version from source, we recommend downloading astroML from the github repository shown above. You must first make sure the dependencies are filled: lacking some of these dependencies will not affect installation, but will affect the ability to execute the code and examples

Both the astroML and astroML_addons packages are installed using python’s distutils. The generic commands for installation are as follows:

python build
python install

The first line builds the source (i.e. for astroML_addons, this compiles the C code used in the package). The second line installs the package so that you can use it from Python. The default install location is in your site_packages or dist_packages directory in your default python path.

If you are on a machine without write access to the default installation location, the location can be specified when installing. For example, you can specify an arbitrary directory for installation using:

python install --prefix='/some/path' Core

The core astroML package is pure python, so the build phase is trivial. The installation script is, and the code can be installed as follows:

python build
python install Addons

The astroML_addons package requires a working C/C++ compiler for installation. It can be installed using:

python build
python install

2.2.3. Testing

After installation, unit tests can be run using the nose testing framework, either by typing nosetests astroML, or by typing make test in the source directory. The latter will also run doc tests on the user guide.

2.3. Dependencies

There are three levels of dependencies in astroML. Core dependencies are required for the core astroML package. Add-on dependencies are required for the performance astroML_addons. Optional dependencies are required to run some (but not all) of the example scripts. Individual example scripts will list their optional dependencies at the top of the file.

2.3.1. Core Dependencies

The core astroML package requires the following:

  • Python version 2.6.x - 2.7.x (astroML does not yet support python 3.x)
  • Numpy >= 1.4
  • Scipy >= 0.7
  • scikit-learn >= 0.10
  • matplotlib >= 0.99
  • astropy >= 0.2.5 AstroPy is required to read Flexible Image Transport System (FITS) files, which are used by several datasets.

This configuration matches the Ubuntu 10.04 LTS release from April 2010, with the addition of scikit-learn.

To run unit tests, you will also need nose >= 0.10

2.3.2. Add-on Dependencies

The fast code in astroML_performance requires a working C/C++ compiler.

2.3.3. Optional Dependencies

Several of the example scripts require specialized or upgraded packages. These requirements are listed at the top of the example scripts.

  • scipy version 0.11 added a sparse graph submodule. The minimum spanning tree example requires scipy >= 0.11
  • pyMC provides a nice interface for Markov-Chain Monte Carlo. Several examples use pyMC for exploration of high-dimensional spaces. The examples were written with pymc version 2.2
  • healpy provides an interface to the HEALPix pixelization scheme, as well as fast spherical harmonic transforms.