STScI Logo
STScI Logo
HST
Banner

STSCI_PYTHON v2.6

Science Software Branch
Space Telescope Science Institute

STSCI_PYTHON is a collection of Python modules, packages and C extensions that has been developed to provide a general astronomical data analysis infrastructure. They can be used standalone from within Python or as Python tasks that are accessible from within STSDAS whens running under PyRAF.

Installing from Source
    Required Supporting Packages
    System Install
    Personal Install

Installing Binaries
    Macintosh
    Windows

PyRAF Setup

Testing the Installation

Assistance

Appendix 1: Platform Specific Notes
    Macintosh
    Linux

Appendix 2: Installing the Supporting Packages

Installing From Source

Required Supporting Packages

As a convenience all supporting packages are available from http://www.stsci.edu/resources/software_hardware/pyraf/support_stsci_python

If you need to install the supporting packages, we suggest that you follow the order in which they are listed below:

 
IRAF

tested with 2.12.2a on Solaris
tested with 2.14 on Linux and Macintosh
STSDAS/TABLES

3.8
Tcl/TK

8.4.13
GNU readline

5.2
Python

2.4 or later, tested with 2.5.1
libf2c

from STScI web site; some users have trouble with native libf2c, especially on 64 bit machines
Pmw

1.3.2
urwid

0.8.7.1 (optional, some users have reported problems with later versions)
ipython

0.8.1 (optional)
NumPy

1.0.4


Some platforms have most of these packages already installed in their system directories. To test whether your Python installation has all modules needed, start Python and try to import them:

% python
>>> import readline
>>> import Tkinter
>>> Tkinter._test()
>>> import Pmw

If you don't get an ImportError, this means that Tcl, Tk, Readline, Python and Pmw are already installed on the system.

The X11 windowing system and a C compiler are needed as well.

Follow the directions on http://iraf.noao.edu/ to get IRAF working on your system.

To facilitate installations, the four packages below are bundled with stsci_python. Convolve, image and ndimage are standalone versions of the corresponding scipy packages. We are distributing them separately to avoid a requirement to install the entire scipy package.

. NumPy 1.0.4
If you need to installNumPy, you will also need a FORTRAN compiler.  Some NumPy documentation is available at http://www.scipy.org/Documentation
. convolve 2.0
. image 2.0
. ndimage 2.0

System Install

The installation directions in this section will perform a default installation in Python's site-packages directory.  You will need root access to do this.  If you do not have (or do not wish to use) root access, it is possible to install in a different directory - skip to the next section ( Personal Install ).

This assumes all supporting packages are present on the system.  If you are missing some supporting packages, see Appendix 1.

Note: If you have a previous installation of stsci_python, it's best to remove the old versions.

Note: The default installation directory of Python packages is Python's site-packages directory, for example:
    /usr/local/lib/python-<version>/site-packages.

IRAF defines environment variables to point to its own versions of F77 and F2C.  You must unset these variables before compiling numpy.

% unsetenv F77
% unsetenv F2C


% gunzip stsci_python_2.6.tar.gz
% tar -xvf stsci_python_2.6.tar

% cd stsci_python_2.6

% cd numpy-1.0.4
% python setup.py install
% cd ..

% cd convolve
% python setup.py install
% cd ..

% cd image
% python setup.py install
% cd ..

% cd ndimage
% python setup.py install
% cd ..

% python setup.py install --with-f2c=<path_to_f2c> ,

where <path_to_f2c> i s the path to the directory with libf2c.a and f2c.h.

To install the stsci_python documentation:

% cd stscidocs
% python setup.py install

Personal Install

For a personal install, the files are installed in a directory that you choose, instead of in the system directories.  When you do this, you need to set the environment variable PYTHONPATH to tell python where to look for the installed modules.

If you install in /home/user/stuff, the package files will be under /home/user/stuff/lib/python and the pyraf program will be in /home/user/stuff/bin.

The sequence of commands would be

% set d=$HOME/stuff
% setenv PYTHONPATH $d/lib/python

% unsetenv F77
% unsetenv F2C


% gunzip stsci_python_2.6.tar.gz
% tar -xvf stsci_python_2.6.tar

% cd stsci_python_2.6

% cd numpy-1.0.4
% python setup.py install --home=$d
% cd ..

% cd convolve
% python setup.py install --home=$d
% cd ..

% cd image
% python setup.py install --home=$d
% cd ..

% cd ndimage
% python setup.py install --home=$d
% cd ..

% python setup.py install --home=$d --with-f2c=<path_to_f2c>

where <path_to_f2c> is the path to the directory with libf2c.a and f2c.h.

To install the stsci_python documentation:

% cd stscidocs
% python setup.py install --home=$d


To start pyraf

% $HOME/stuff/bin/pyraf

Installing Binaries

Macintosh

Installing

The Macintosh binaries are distributed as a Macintosh package.  This package includes all of
    - IRAF
    - STSDAS/TABLES
    - Python and supporting code
    - STSCI_PYTHON
in a single package.  This is the same package that we use internally at the Institute.

You must be an administrator to install this package.

Download the appropriate DMG file from http://www.stsci.edu/resources/software_hardware/pyraf/stsci_python/current/download .  Pick the PPC file if you have a PowerPC based Macintosh, or the Intel file if you have an Intel based Macintosh.

Double-click on the .dmg file, then double-click on the .pkg file in the window that appears.  This runs the standard Macintosh installer.  Click "Continue" to move through the various screens of the install and enter your password when prompted. 

Most of the package is installed in /usr/stsci.  IRAF assumes that there is only one IRAF installation on any computer and it places symlinks at various places about the system.  There may be some conflict if you have multiple copies of IRAF installed, but 2.12, 2.13, and 2.14 appear to be similar enough that it is not a great problem unless you are compiling IRAF from source code.

Warning:  This package and future releases will attempt to remove any previously installed copies of itself.  That means that changes to the software in /usr/stsci will be lost if you run the installer again.  We strongly suggest that you do not make changes to the software in /usr/stsci.  Notably, add new IRAF tasks by editing your login.cl file and install python packages with --home or --prefix.

User Configuration

Each user who wants to use the software from this package must execute these two commands:

        source /usr/stsci/envconfig.mac/cshrc
        iraf

We suggest that you place these commands at the end of your .cshrc file.  There are many environment variables involved, and you may have problems if you override their values.

Note:  This package is essentially the same thing that we use internally at STScI.  If you examine the script file, you will find aliases for "irafx" and "irafdev".  These are test configurations that we use internally; they are not distributed with this package.

Windows

The Windows binaries are distributed as five Windows installer files.  The are available from http://www.stsci.edu/WHERE.  Download and double-click each one to install it:

    - image
    - ndimage
    - convolve
    - numpy
    - stsci_python


PyRAF Setup

After a default installation the pyraf startup script is located in the same directory with the python executable, so this directory has to be on the search path. Modify the environment variable $PATH if necessary. If the software was installed in a personal directory, with either "--home=<install-dir>" or "--prefix=<install-dir>", then the startup script is located in <install-dir>/bin.

Testing the Installation

The script testpk.py can be used to check the integrity and version compatibility of the installation.

Note: This script must be run from a directory other than stsci_python, for example your home directory. Make sure that $PYTHONPATH is correct.

% cp stsci_python/testpk.py ~
% cd
% python testpk.py

Assistance

If you have any difficulties with the installation of any of the packages in stsci_python, please do not hesitate to contact us for assistance. Also, if you have questions or suggestions about stsci_python in general or this document and want access to modify it contact us at help@stsci.edu. We hope that people can contribute tips to the platform specific part of this document.

Appendix 1:  Platform Specific Notes

Macintosh


- Iraf and stsci_python need X11 and will NOT work with the version of python distributed with the operating system (/usr/bin/python) or with macpython. X11 based versions of Tcl/Tk and Python are required.

- On MacOSX the installation was tested with the supporting packages installed from sources on the Unix command line, but installations of the supporting packages can be done using fink ( http://fink.sourceforge.net/ ).

Some of the packages don't have binaries available from fink.  Python MUST be installed from source using fink, in order to get Tkinter working. If fink was used for installations of supporting packages on MacOSX, make sure you are running python in /sw/bin when you attempt to install stsci_python.

- Compilers can be installed with the Developer's tools.

Linux

- The packaging systems for the various flavors of Linux can be used to install the supporting packages. For example, on Redhat rpms can be used for supporting packages. However, Tkinter rpms should be matched with the version of python and the operating system. On a Linux system, the rpms for these packages are on the installation CD. Both libraries and the header files are needed for the installation.

- Problems runnning graphics tasks in Pyraf were reported on some operating systems (for example Ubuntu and Suse). The errror message is

TclError: expected floating point number but got "1.0"

Although we do not understand the reasons for this we know it is caused by a default non-english locale on the system. One possible solution is to start pyraf by running:

env LC_ALL=C pyraf

Appendix 2: Installing the Supporting Packages


Some of the packages require IRAF to be present on the system. IRAF installation is not discussed in this document. IRAF is maintained by the iraf group at NOAO. For installation instructions or problems, see http://www.iraf.net.

Note: A full installation of the supporting packages is needed, including libraries and header files. On some operating systems the header files may be in a separate package. For example onRedhat they are in the corresponding "devel" rpm package.

If installation from source is necessary, on most systems the following will work:

To unpack a source file:

% gunzip package.tar.gz
% tar -xvf package.tar

ยท To configure and build a package:

% cd package
% ./configure --prefix=<installation-directory>
% make
% make install

This will create directories bin, lib, include under <installation-directory>. The option "--prefix=" in the above "./configure" command may be omitted for installations in /usr/local.

If you install any of these packages in a personal directory, you will most likely need to change two environment variables:

setenv LD_LIBRARY_PATH <installation-directory>/lib:$LD_LIBRARY_PATH
setenv PATH <installation-directory>/bin:$PATH

or set them

setenv LD_LIBRARY_PATH <installation-directory>/lib
setenv PATH <installation-directory>/bin

Tcl/Tk

It is very likely that Tcl and Tk are already installed on your system. Look in the system directories for files like libtcl.* and libtk.*. PythonTcl/Tk v8.3 or later.

If you have to build these packages from source, build them as shared libraries. On most systems the following set of commands will work for Tcl and Tk:

% cd tcl8.3.5/unix
% ./configure --enable-shared --prefix=<installation-directory>
% make
% make install

Readline

Readline is probably already installed on your system. Make sure the header files are installed as well. A possible location to look for them is /usr/include/readline. In case you need to install Readline in your personal directories, the following commands will install it on most systems:

% cd readline
% ./configure --prefix=<installation-directory>
% make
% make install

Python

Source Installation: Python is available from the python web site at http://www.python.org/ . If Tcl/Tk and Readline libraries are on LD_LIBRARY_PATH or in a system directory, the next three commands are usually sufficient to install Python from source:

% cd python
% ./configure --prefix=<installation-directory>
% make
% make install

To test whether your Python installation has all required modules enabled, try to import the modules as described in Section 1.0.

To build Tkinter, you may need to edit the file Modules/Setup in the Python source distribution, to let Python know where Tcl/Tk and X11 libraries are. Below is an example of this section of the Setup file on Solaris. Note, that some lines are uncommented and the paths on your system may be different.

# The _tkinter module.
#
# The command for _tkinter is long and site specific. Please
# uncomment and/or edit those parts as indicated. If you don't have a
# specific extension (e.g. Tix or BLT), leave the corresponding line
# commented out. (Leave the trailing backslashes in! If you
# experience strange errors, you may want to join all uncommented
# lines and remove the backslashes -- the backslash interpretation is
# done by the shell's "read" command and it may not be implemented on
# every system.
# *** Always uncomment this (leave the leading underscore in!):
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
-L/usr/local/lib \
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
-I/usr/local/include \
# *** Uncomment and edit to reflect where your X11 header files are:
# -I/usr/X11R6/include \
# *** Or uncomment this for Solaris:
-I/usr/openwin/include \
# *** Uncomment and edit for Tix extension only:
# -DWITH_TIX -ltix8.1.8.2 \
# *** Uncomment and edit for BLT extension only:
# -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \
# *** Uncomment and edit for PIL (TkImaging) extension only:
# (See http://www.pythonware.com/products/pil/ for more info)
# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
# *** Uncomment and edit for TOGL extension only:
# -DWITH_TOGL togl.c \
# *** Uncomment and edit to reflect your Tcl/Tk versions:
-ltk8.3 -ltcl8.3 \
# *** Uncomment and edit to reflect where your X11 libraries are:
# -L/usr/X11R6/lib \
# *** Or uncomment this for Solaris:
-L/usr/openwin/lib \
# *** Uncomment these for TOGL extension only:
# -lGL -lGLU -lXext -lXmu \
# *** Uncomment for AIX \
# -lld \
# *** Always uncomment this; X11 libraries to link with:
-lX11

libf2c

Note: The libf2c package at http://www.stsci.edu/resources/software_hardware/pyraf/support_stsci_python supports all platforms on which stsci_python is supported. We recommend installing it.

If a source installation is needed, download the package from our web site. It is needed only at compile time but it is worth installing it permanently on the system for future upgrades of stsci_python. The following commands will build it:

% tar xvf libf2c.tar
% cd libf2c
% make -f <makefile.os>

Substitute makefile.os with the correct makefile for your operating system. For example for 64 bit linux operating systems use:

% make -f makefile.linux64

After building libf2c the two files that are needed, f2c.h and libf2c.a, will be located in the source directory. They can be moved to a permanent location. For example they can be copied to /usr/local/libf2c in which case this directory should be used for building stsci_python.

Urwid

Urwid can be installed optionally. It is needed for support of tpar (a text based epar) in PyRAF. It can be installed by :

% python setup.py install

Ipython


Ipython   can be installed optionally as well. If available PyRAF can run in the Ipython interpreter (pyraf --ipython). To install Ipython, execute the command:

% python setup.py install






















Copyright  | Help  | Printable Page