Installing the required packages for Spire

Required packages
Installation notes
Default installation directories
The PATH and multiple program versions
Tcl/Tk
Installing Tcl/Tk
The BLT package
Python
Checking Python version
Installing Python
Which executable version of Python is running?
Is Python seeing the correct Tcl/Tk?
Python packages
The site-packages directory
Does Python have Tk?
Pmw
Can Python access BLT?
PIL : the Python Imaging Library
Numpy
Gnuplot for Python


Required packages

Spire requires SPIDER version 13 or later.

Spire is written in Python, and requires Python version 2.3 or later. For graphics, it uses Tkinter, the Python interface to Tcl/Tk (version 8.4 or later). Spire requires the following software packages (your system may already have these installed):

Tcl/Tk8.4 (or later) www.tcl.tk/software/tcltk
BLT sourceforge.net/projects/blt
Python2.3 (or later) www.python.org/download
Python megawidgets (Pmw) sourceforge.net/projects/pmw
Python Imaging Library (PIL) www.pythonware.com/products/pil
Numpy sourceforge.net/projects/numpy
Gnuplot.py gnuplot-py.sourceforge.net


Installation notes

  1. Default installation directories

    Where a directory name is indicated in the examples below, be sure to substitute your own local directory.

    On Linux most of the following packages are installed in directories under /usr/local by default. A different installation directory may be specified, usually with the software package's configure command:

        ./configure  --prefix=/your_preferred_installation_directory
    
    If you specify the installation directory, then make sure all packages refer to the same directory.

    NB: The installation directory is different from the source directory. The source directory is where you extract the *.tar.gz files, while the installation directory is the destination of the libraries and executables.

  2. The PATH variable and multiple program versions

    Sometimes multiple versions of a software packages are installed in different directories. This can result in considerable confusion unless you specify explicitly which version of Python, Tcl/Tk, etc. you wish to use. The PATH environmental variable is a list of directories that are searched for executable programs. The following presumes some basic knowledge about Unix and the PATH variable, and also assumes you are running the C shell.

    To see your path, type the following at the Unix prompt (here shown as #)

        # echo $PATH
        /bin:/usr/bin:/usr/local/bin:.
    
    This indicates that when a command is typed at the system prompt, these four directories (bin, /usr/bin, /usr/local/bin, and ".") are seached for an executable program. Often the path is set in the user's .cshrc file. You may have to alter your path to make sure that when you type python or tclsh, the desired version is executed. After editing your .cshrc file to make path changes, you must run source ~/.cshrc before the changes can take effect (or open a new Unix window).

    The Unix where command lists all locations of a program that can be found on your path:

         # where python
        /usr/bin/python
        /usr/local/bin/python
    
    This listing shows there are two versions of Python installed.
    The Unix which command shows which program would actually get executed from the command line.
         # which python
        /usr/bin/python
    
    This indicates that /usr/bin/python would be executed if I typed in "python", because /usr/bin comes before /usr/local/bin on my path.

  3. The extract command shown below is a little script you can easily make:
    type gunzip < $1 | tar xvf - into a file called "extract", and make it executable: chmod 775 extract
  4. If you encounter an error and need to run make again, first run make clean to remove old files. To see options of the configure command, use
        ./configure --help
    

Tcl/Tk

Tcl and Tk are two different packages, and each must be installed. Tk, the graphics part, requires that Tcl is already installed.

Check the Tcl version: At the Unix prompt, type tclsh. This starts the Tcl prompt (%). To see the version, type info tclversion:

    # tclsh
    % info tclversion
    8.4
    % exit
(info patchlevel gives more version detail.)

If the version is 8.4 or greater, see if BLT is installed

If tclsh is not found, or the version is less than 8.4, then install Tcl and Tk

Installing Tcl and Tk

In the steps below, substitute your version for "8.4.x", and replace "/your/install/dir" with your actual installation directory.

In the source directory with the zipped tcl tar file, extract the tar file, change to the tcl directory, and run the config program:
    extract tcl8.4.x-src.tar.gz           # or:  gunzip tcl8.4.x-src.tar.gz | tar xvf
    cd tcl8.4.x/unix 
    ./configure  --prefix=/your/install/dir
or just
    ./configure
If you do not specify a directory, Tcl will be installed under the /usr/local tree. After setting the configuration, compile the program:
    make 
    make install
    cd ../..
Then install Tk:
    extract tk8.4.x-src.tar.gz
    cd tk8.4.x/unix
    ./configure  --prefix=/your/install/dir           # same dir as above
    make
    make install
    cd ../..

The executable files (tclsh8.4 and wish8.4) should now be in /your/install_dir/bin. For instance, if you installed Tcl with
./configure --prefix=/usr/local/spire
then the above executables will be in /usr/local/spire/bin. This bin directory should be on your path (before any others with conflicting versions of Tcl/Tk). E.g., you can add the following line to the end of your .cshrc file:

 set path =(/usr/your/install/dir/bin  $path)

If you type tclsh at the Unix prompt, it may not find the newly installed version, because the name is actually tclsh8.4. One way around this is to make a symbolic link to the executable (Tk runs as a program called wish):

    cd /usr/your/install/dir/bin
    ln -s tclsh8.4 tclsh
    ln -s wish8.4 wish
If you now have
multiple versions of Tcl, check which one gets executed. At the tclsh prompt, use the command info nameofexecutable to see the program that gets called when you type tclsh:
    # tclsh
    % info nameofexecutable
    /your/install/dir/bin/tclsh8.4
You should see bin/tclsh8.4 in the desired directory (e.g., the installation directory you specified with the ./configure command).

BLT : a plotting package for Tk

Does Tcl have the BLT library?

At the Tcl prompt (%), see if BLT is available with the package require command. If it finds BLT, it will print out the version:
    # tclsh
    % package require BLT
    2.4

If can't find it, then install BLT

Installing BLT

Do the usual:
    extract  BLT2.4z.tar.gz
    cd blt2.4z
    ./configure --prefix=/your/install/dir 
    make
    make install
Check if your Tcl version now has the BLT package (you may have to source .cshrc or open a new window). Before you can check
if Python can access BLT, you need to have the Pmw package installed.

The graphics tools ctfdemo.py, ctfmatch.py, and ctfgroup.py use the BLT package.


Python

Check the version of Python

At the Unix prompt, type python, which gives you the python prompt (>>>). The version number appears right after the word "Python".
    # python
    Python 2.3.3 (#2, May 25 2004, 10:53:39) [C] on irix6
    >>> (ctrl-D exits)
If the version is 2.3 or greater, then
see if Python can access Tk.
If Python is not found or the version is less than 2.3, then install Python.

Installing Python

Substitute your Python version in place of "Python-2.5.1" below.
    extract Python-2.5.1.tgz
    cd Python-2.5.1
    ./configure --prefix=/your/install/dir
    make
   (make test)          # optional. It takes awhile.
    make install
In a new window, can you run the
correct version of Python? (you may have to source .cshrc or open a new window).

Which executable version of Python is running?

You can check if the python running is in fact the one you just installed by viewing the sys.executable attribute in Python:

   # python
   >>> import sys
   >>> sys.executable
   '/your/install/dir/bin/python2.5'
You can also check
Python's internal path to see if it is in the correct location.

Is Python seeing the correct Tcl/Tk?

Import Tkinter and start a Tk process (root), then use the process to send a command to Tcl:

>>> import Tkinter
>>> root = Tkinter.Tk()
>>> root.tk.eval('info library')
'/your/install/dir/lib/tcl8.4'
You should see lib/tcl8.4 in the directory containing the desired Tcl version.


Packages for Python

The site-packages directory

Packages are loaded into Python with the import command. Generally, you will get an error message if Python cannot import the package, otherwise it simply returns the Python prompt. Usually the package's setup.py program automatically installs the package into the Python site_packages directory. But sometimes you must copy the files there yourself. To find where the site_packages directory resides, import the sys module and view its path attribute:

    # python
    >>> import sys
    >>> sys.path
    ['/usr/local/spire/lib/python25.zip','/usr/local/spire/lib/python2.5','/usr/local/spire/lib/python2.5/plat-linux2',...]
sys.path is the list of directories Python searches. To make it a little easier to read, try:
    >>> for p in sys.path: print p
    ... 

    /usr/local/spire/lib/python25.zip
    /usr/local/spire/lib/python2.5
    /usr/local/spire/lib/python2.5/plat-linux2
    /usr/local/spire/lib/python2.5/lib-tk
    /usr/local/spire/lib/python2.5/lib-dynload
    /usr/local/spire/lib/python2.5/site-packages
    >>> 
In this example, Python was installed under /usr/local/spire, and the site-packages directory is /usr/local/spire/lib/python2.4/site-packages.

Does Python have Tk?

Can Python access Tk? And is it the correct version? The Python interface to Tk is called Tkinter. Be careful with capitalization:

    # python
    >>> import Tkinter
    >>> Tkinter.TkVersion
    8.4
If it can't import Tkinter, or you see the wrong version, check that you're running the
correct version of Python when you type python at the Unix prompt (that is, the version you installed).

Pmw : Python Megawidgets

See if Pmw is installed. Try to import Pmw at the Python prompt:

    >>> import Pmw
    ImportError: No module named Pmw
If it cannot find Pmw, check
the Python version.
If Python is the correct version, then Pmw is not present: install Pmw.

Installing Pmw

Download and extract the Pmw distribution. There is no configuration or make, just copy the Pmw directory to the site_packages directory:

    cp -r Pmw /usr/local/spire/lib/python2.4/site-packages
Check that Python can now import Pmw.

Can Python access BLT?

Python accesses BLT via Pmw, so you need to first import Tkinter and Pmw, then start a Tkinter root window:
    # python
    >>> import Tkinter
    >>> import Pmw
    >>> root = Tkinter.Tk()
    >>> Pmw.Blt.haveblt(root)
    True
If it does not return True, check that
Python is accessing the correct Tcl, and that Tcl has BLT.


The following 3 packages usually just install with a variant of setup.py (or python setup.py).

PIL : the Python Imaging Library

PIL version 1.1.6 can handle the SPIDER image format.

   # extract Imaging-1.1.6.tar.gz
   # cd Imaging-1.1.6
   # python setup.py install
Then you should be able to import the Image module:
   # python
   >>> import Image
   >>>

The graphics tools qview.py, montage.py, and classavg.py use the Image module.

Numpy

Numpy, a Python package for scientific computing, is required by Gnuplot.py.

   extract numpy-1.1.1.tar.gz
   cd numpy-1.1.1
   python setup.py install

In addition, you can can convert SPIDER images into Numeric arrays using the SPIDER Python Library.

Gnuplot for Python

Gnuplot.py is an interface that allows a Python program to send commands to gnuplot. Therefore it requires that gnuplot is installed.

   extract gnuplot-py-1.8.tar.gz
   cd gnuplot-py-1.8
   python setup.py install

The pyplot.py utility uses the Gnuplot module.