Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Data / SNooPy / Installing SNooPy2

Installing SNooPy2

SNooPy2 has seen a number of changes that were motivated by making the installing process less painful (for you and me!).  I  have tried to update to the latest and most stable python modules and remove the cruft that was simply too difficult to run on modern operating systems (PGPLOT being the major culprit). You now have 4 options for installing SNooPy:

  1. Install using an install script
  2. Install as an Anaconda package
  3. Install using pip
  4. Install yourself from source code.

Installing SNooPy using the Install Script.

Download the bootstrap install script. Go to a folder where you want to install SNooPy. Then run the following in a terminal:

% python snpy-bootstrap.py folder

This will install SNooPy into folder (replace with whatever name you want). Run SNooPy:

% /path/to/folder/bin/snpy

Under the hood, the install script will try to create a virtual environment, install the required dependencies, then download the source code from github and build SNooPy. The advantage here is that the 'update-snpy' script will now be able to pull from github and get the feature enhancements and bug fixes as they are uploaded to the repository. Every now and then, SNooPy will give you a warning message that an update is available.

The script is smart enough to detect if you are already using a virtual environment or conda environment and act accordingly.You should get a friendly message at the end letting you know exactly where SNooPy was installed and how to run it.

Installing SNooPy as an Anaconda package

If you already have the Anaconda Python distribtution, it's very simple to install SNooPy. First, you will have to add my Anaconda cloud channel to your config:

% conda config --add channels cburns1

Next, I recommend you create a new conda environment for using SNooPy (to minimize the chance of package conflicts):

% conda create -n snpy snpy

Then you simply activate the snpy environment whenever you want to run SNooPy:

% source activate snpy

The downside of using the Anaconda package is you will only get updates to SNooPy when I get around to updating the Anaconda package. I will try to do so regularly, but if you want to stay on the bleeding edge, consider using the install script method instead (which can be run from inside a conda environment).

Installing SNooPy using pip

Now that SNooPy has a page on PyPI (the Python Cheese Shop), you can use 'pip' to install SNooPy. The pip installer knows how to satisfy dependencies, so it should be as simple as running:

% pip install snpy

However, it is possible to end up with conflicts if SNooPy needs a newer version of a package you already have installed. The other downside, like the anaconda solution, is that you will only get updates when I get around to updating PyPI, which I will try to do regularly, but if you want to be able to get the up-to-the-minute changes, consider the next solution below.

Installing SNooPy Yourself From Source

Welcome Jedi. You probably know what you're doing if you're reading this section, but nevertheless, allow me to provide some tips on building SNooPy yourself.

1 - Get a Python Distribution

Most systems come with python pre-installed and you are free to use the system python if you wish, as long as it is version 2.6 or newer.  However, there are several other binary distributions that come pre-packaged with many of the scientific modules needed by SNooPy and are therefore less likely to have the installer fail with compile-time errors.  For this reason, I highly recommend installing one of these, especially if you are working in Windows or a Mac (whose operating systems by default do not come with all the compilers and tools one typically needs to build software).  I recommend Anaconda (free) or the Enthought Python Distribution (free for academics) which run on Linux, MacOS, and Windows.  I do all my development using the Carnegie Python Distribution (CarPy), so that's also a good choice, though can be trickier to install than Enthought.  Ureka is also very popular with astronomers and I have reports that SNooPy installs fine (as long as you unset the F77 environment variable before running the bootstrap script). But wait! Now Ureka is piggy-backing on Anaconda as Astroconda! See table below for a comparative list of distributions.

Get the distribution of your choice, activate it in your shell (usually running a setup script of some kind).  Make sure that when you run "python" on the terminal, you get the correct one.  You can check this on Unix-type systems by typing 'which python'.  For example:

% which python
/Library/Frameworks/Python.Framework/Versions/Current/bin/python

This is what you get if you install Enthought on a Mac.

If you are one of those people who wants to "roll your own" or have some crazy setup where you simply must install the python modules yourself, then there is a list of required modules at the bottom of the page.  Go and install those before you go on to the next step (or you can let the bootstrap script try to do it for you).

2- Install C/Fortran Compilers if needed

If some of the software required to run SNooPy2 is missing, the installer will attempt to download and compile it.  For this, it will require a C compiler and possibly a Fortran compiler.  For Linux systems, simply install the appropriate RPMs.  For Mac OS users, see this page for details about how to set up your compilers properly.

3- Download SNooPy Source from Github and Install

In some source location, run the following command to get the latest SNooPy code:

git clone https://github.com/obscode/snpy.git snpy

NOTE:  if you have been using the old SVN repository, it will continue to be updated, but it is simply a mirror of the github repository (using the subgit software package).

Now all that's left is to run the setup script as usual:

% cd snpy
% python setup.py install

4 - Run SNooPy2

The setup script will install the snpy startup script into some default location, hopefully in your path, so starting SNooPy should be as simple as:

% snpy

And that's it.  SNooPy should start up.  Try plotting some light-curves and make sure that the new plotting engine (matplotlib) works correctly.  If you wish to use SNooPy non-interactively (write some scripts that import snpy), then you must run those scripts with the same python that was used to install:

% python my-great-script.py

If you don't use the correct python, then your script will bomb and complain it can't find the snpy module.

5 - Keep Up To Date

Along with the snpy start-up script, there is also a 'update-snpy' script. You can use this to download and install the latest fixes to SNooPy. Every now and then, SNooPy may give you a message at startup that an update is available for download. On rare occasions, the update script itself may need to be updated, in which case you will need to run 'update-snpy' twice (first time updates the update script, second time runs the updated update script).

6 - When Things Go Wrong

I've tried to make this fool-proof, but there are SO many OS/architecture/compiler combinations out there that I can't possible anticipate everything.  I'll be happy to help you out if the compiling bombs out, but please please PLEASE try installing one of the binary python distributions mentioned in step 1 for your system.  That will get us 95% of the way there! Check out the "compiling SNooPy" section of the FAQ, you might find a solution to your problem there.

Required Modules

Here is a table showing what's needed and if it's available in several popular python distributions.  The version in parentheses are the versions I use when developing.  You will need a C compiler and a fortran compiler (gfortran) in order to build certain packages from source.  Note:  many of these can be installed using setuptools' easy_install script.

CSP Data and StuffPackage 
CSP Data and Stuff
CSP Data and StuffScisoft OS X
CSP Data and Stuff
CSP Data and StuffCarPy CSP Data and StuffEnthought CanopyUrekaAnaconda
Python  (2.7.3) yes  yes yes yes yes
iPython (2.1.0) yes yes yes yes yes
Numpy (1.8.1) yes yes yes yes yes
Scipy  (0.11.0) yes  yes yes yes yes
Pyfits (3.1.1)* yes  yes yes (via package manager) yes no (use pip)
matplotlib (1.3.0) yes yes yes yes yes
pymysql 0.7.9** no no yes (via package manager) yes yes (via conda)
pymc (2.2)*** yes yes yes (via package manager) no yes (via conda)
astropy (1.0.4)* no yes yes (via package manager) yes yes (via conda)
emcee (2.1.0)*** no yes yes (via package manager) no no (use pip)

* SNooPy either needs Pyfits or the io.fits module in astropy. Install at least one of these. astropy gives SNooPy the ability to compute distance moduli based on cosmology

** only needed for the CSP internal version of SNooPy (to access our SQL database) or if you want to setup your own SQL database.

*** optional.  Pymc allows SNooPy to interpolate light-curves using Gaussian Processes (which is wicked cool, so you want to get this!), and emcee is needed to use the new MCMC fitting functionality.