Loading...
 
(Cached)

 

Cautionary Note: This page may be out of date

Note: The below guide was last updated in Fall 2011. For a slightly more recent (March 2012) take on how best to install scientific Python, see http://python4astronomers.github.com/installation/python_install.html

Partial update in May 2013, May 2014

 

Setting up Python for Astronomy

Installing Python Itself

There are many different ways to get to a functioning Python install for astronomy. Many of the existing guides elsewhere advocate one particular method or another. The goal of this page is to list all your choices, and a few sentences about their various pros and cons. 

Most new users on Macs should select the either Anaconda or Enthought Canopy (formerly Enthought Python Distribution). However, if you are already using the Macports package manager to install other Unix-related tools, then Macports is also an excellent choice for Python. If you will be using IRAF, then Scisoft is also highly recommended.

In addition to various different installation methods, there are different versions of Python itself. Most importantly, there is ongoing development of Python 3, which due to some changes in the language syntax is not back-compatible with code for any version of Python 2. Overgeneralizing broadly, Python 3 is the future, Python 2 is the present. For almost all astronomers, Python 2.7 is the most useful and recommended language version.

So, how can you get Python going?  The following options are ranked loosely based on one author's subjective impression of how useful each is for a typical user. See the python4astronomers installation options list for a cross platform comparison.

  • Anaconda is a binary distribution provided by one of the leading scientific python commercial developers. It comes with a large library of modules including the complete scientific python stack, is free to academic users, and is becoming the most widely recommended Python version for scientific work. 
  • Enthought Canopy (formerly Enthough Python Distribution, EPD) is another binary distribution including all the standard modules, also free to academic users. It's probably equally as good as Anaconda for most purposes.   See the python4astronomers tutorial for detailed instructions for using this.
  • Macports is a general package manager inspired by BSD Unix's ports system, and it includes increasingly good support for astronomical python routines among the many thousands of installable packages.  If all you want is Python, it's not worth the overhead of setting this up, but if you're already using Macports then it's a straightforward way to install Python. The primary caveat is that Macports installs from source, and the compilation steps for numpy and scipy and matplotlib can be pretty time consuming (a couple hours or so. A full installation easily completes overnight). The payoff is that you'll have up-to-date versions of the code optimized for your particular hardware.
  • scisoft. The scisoft package contains a copy of Python, along with many other astronomy related software packages such as IRAF/PyRAF, ds9, XEphem, etc. Scisoft requires the least number of steps to install and has up-to-date versions of numpy, scipy, and matplotlib as of July 1, 2011. If you plan to use IRAF and python, scisoft is highly recommended.
  • The Scipy Superpack provides easy binary installation of the basic packages (Numpy, Scipy, Matplotlib, IPython).  Only OS X Lion is presently supported.
  • ActiveState Community Python Distribution. (aka ActivePython). This is another binary distribution with some differences from EPD. It is less commonly used but also apparently has good functionality.  See the python4astronomers tutorial or this page for more details.
  • Compile your own Python from source. This is certainly doable, but likely only of interest to serious developers. In which case you should maybe be contributing to this guide rather than just reading it! 
  • MacPython. This is the official version of the core language released by the develooment team at python.org. See http://www.python.org/download/mac/. If you choose this path, you will have to separately install all the required packages starting with numpy and scipy. This is probably more work than it is worth. 
  • Use your computer's built-in python? For Mac OSX, no. For Linux, probably.  This is not recommended for Mac users, as the version Apple ships is usually fairly old.  This may (or may not) get better with OS X Lion.  For Linux users, distributions such as Red Hat and Ubuntu appear to have pretty good support for numpy etc within their native package managers, though almost certainly some  astronomy modules will be missing from there. 
  • Fink. Another package manager, derived from Debian Linux apt. This appears to have less support in the astronomical community than Macports, and is not recommended. However, it does include packages for numpy+scipy+matplotlib, and for some but not all of the more astronomy specific packages. (comments or suggestions from anyone successfully using this method?)

 

Installing Additional Modules

 

PYPI and pip: Most commonly used Python modules can be installed from the PYPI repository.

The current recommended method for doing this is the command line tool 'pip', for Python Installs Packages. (This replaces the older command 'easy_install'. If you see any references to easy_install in web pages, you can in general substitute pip instead.)  

See this page (scroll down a bit) for copy-and-pastable commands for using pip to install the primary required astronomical modules.  (Currently, the first step is to use easy_install to install pip itself. This is necessary because EPD for some reason does not include pip. Hopefully this will be fixed in future versions.)

 

Macports: For users of Macports, most of the core modules may be installed via macports as well. This includes numpy and scipy, of course, but also many more astronomy-specific modules. The primary caveat to be aware of is that the package names are prefixed for the Python version, e.g. 'py27-scipy', 'py27-pyfits'.  

It is perfectly acceptable to mix pip and Macports installation methods; packages installed in both ways will be similarly available for importing inside your Python sessions.

 

Detailed Comments on Installation Methods

 

This section should eventually have more detailed installation instructions for the various possible methods...

 

Suggested module list for pip

This list assumes you already have numpy, scipy, etc. and just want to install some useful astronomy modules.  This is far from a complete list. See the astropython resources page for many more. 

 

pip install astropy
pip install aplpy
pip install pyregion
pip install pyparsing

Suggested module list for Macports

Same caveats as for the pip list, above. 

 

port install py27-astropy
port install py27-aplpy
port install py27-pyregion
port install py27-vo
Page last modified on Monday 02 of June, 2014 19:23:26 EDT