Abstract
STSCI_PYTHON is a collection of Python packages (with 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.
STSCI_PYTHON is developed by the Science Software Branch
at the Space Telescope Science Institute.
If you need to install the supporting packages, we suggest that you follow the order in which they are listed below:
Many of the supporting packages are available for download from http://www.stsci.edu/resources/software_hardware/pyraf/support_stsci_python
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, Numpy source code is included in the stsci_python distribution. Some NumPy documentation is available at http://www.scipy.org/Documentation
If you have an earlier version of STSCI_PYTHON installed, you should
either remove it or ensure that it is not present on your PYTHONPATH.
Python does not have a facility to uninstall packages, but you can
use the uninstall.py script to assist you. It attempts to locate
things that look like they might be part of a previous stsci_python
installation. For each thing that uninstall.py locates, it will
describe it and then offer to delete it for you. If you want to
delete it, type "y" and press enter. If you want to skip it, just
press enter.
python uninstall.py
For a personal install, the files are installed in a directory that
you choose, instead of in the system directories. For example, 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.
You will need this set of commands to set up the environment. Other
users can also run from your copy of the software by setting the
environment variables to point to the same directories.
Enter these commands now, and also place them in your .login or .cshrc file:
set d=$HOME/stuff
setenv PYTHONPATH $d/lib/python
set path = ( $d/bin $path )
Extract the tar file:
% gunzip stsci_python_2.9.tar.gz
% tar -xvf stsci_python_2.9.tar
use gtar (gnu tar) on Solaris
% cd stsci_python_2.9
If you need numpy, install it:
% cd numpy-1.3.0
% unsetenv F77
% unsetenv F2C
% python setup.py install --home=$d
% cd ..
Install the stsci_python package:
% python setup.py install --home=$d
(optional) Install the stsci_python documentation:
% cd stscidocs
% python setup.py install --home=$d
If you are root, you can install stsci_python in the system python
directories, where it will be available to all users. The commands
are almost the same as for a personal install, but you do not need
to specify the directory to install.
To install stsci_python, you must unset these environment variables that were set by IRAF:
Extract the tar file:
% gunzip stsci_python_2.7.tar.gz
% tar -xvf stsci_python_2.7.tar
use gtar (gnu tar) on Solaris
% cd stsci_python_2.7
If you need numpy, install it:
% cd numpy-1.3.0
% unsetenv F77
% unsetenv F2C
% python setup.py install
% cd ..
Install the stsci_python package:
% python setup.py install
(optional) Install the stsci_python documentation:
% cd stscidocs
% python setup.py install
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 testpk.py ~
% cd
% python testpk.py
Some of the packages require IRAF to be present on the system. IRAF
installation is not discussed in this document; it 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 on Redhat
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=/example
% make
% make install
This will create directories bin, lib, include under /example. 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 set your path:
% set path ( /example/bin $path )
and change LD_LIBRARY_PATH with one of these commands:
% setenv LD_LIBRARY_PATH /example/lib:$LD_LIBRARY_PATH
% setenv PATH /example/bin:$PATH
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.*.
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 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
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 as part of Python, 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
As of stsci_python 2.7, it is no longer necessary to provide libf2c.
Urwid ( http://excess.org/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 ( http://ipython.scipy.org/moin/ ) 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