Installing PyMOL and cctbx
Queen's University Protein Function Discovery
and Department of Biomedical and Molecular Sciences
Molecular Modelling and Crystallographic Computing Facility
Crystallography and Modelling:
Other:

Installing PyMOL and cctbx

Getting PyMOL to play nicely with cctbx can sometimes be a chore. In order to get the two projects to use the same version of python, you need to install both of them from source.

I install cctbx from source, although you could use one of the self-extracting binary distributions:

CCTBX installation instructions

  1. Download the self-extracting source from the cctbx downloads page
  2. put the file self_bundle.selfx in new directory, e.g. /usr/local/cctbx, and then
  3. run the command perl self_bundle.selfx
  4. Note the creation of the file: cctbx_build/setpath.sh and cctbx_build/setpath.csh. You will need to run one of these, depending on whether you use a bash-like or csh-like shell, to allow subsequent python commands to see the newly installed cctbx modules.
  5. In the cctbx_build/bin directory there is a cctbx.python file. Make sure there is a symbolic link to that called python. I.e.
      ln -s cctbx.python python
      
    Once the cctbx setup script is run, this directory will be in your PATH and it will run your system python, but it will also set up up the necessary environment for cctbx.
I personally use PyMOL installed from the SVN source to have the latest and greatest features.

PyMOL installation instructions

  1. Download (or update) PyMOL via SVN. I use a little script that looks like this:
    
      #! /bin/sh
    
      usage() {
        echo -e "\nsvn_update.sh [options]"
        echo      "where [options] could be:"
        echo      "     --backup|--back   Make backup copy"
      }
    
      svnbackup() {
        echo "Making backup copy (in case something goes wrong ...)"
        cd pymol && tar cf - . | ( cd ../old_pymol && tar xf - )
        cd ../
      }
    
      svnupdate () {
        svn checkout https://pymol.svn.sourceforge.net/svnroot/pymol/trunk/pymol pymol
      }
    
      if [[ "$#argv" < 1 ]] ; then
        svnupdate
      else
        if [[ "$1" == "-h" || "$1" == "--help" ]]; then
          usage
      # don't do backup unless "back" flag is given
        elif [[ "$1" == "--back" || "$1" == "--backup" ]]; then
          svnbackup
          svnupdate
        else
          svnupdate
        fi
      fi
    
    This will download the pymol source into the "pymol" directory.
  2. Now you just need to run a few commands:
      python setup.py build
      python setup.py install
      python setup2.py install
      
    Optionally, you can specify an installation location with the "prefix" option to the setup.py install command. For example, I store all of our software on an NFS accessible disk that is mounted as "/software" and the python libraries for our Linux computers are installed in /software/Linux/lib/python2.6/site-packages so I do this as:
      python setup.py install prefix=/software/Linux
      
      
  3. I modify the pymol script that starts pymol, so that it looks like this:
      #!/bin/sh
      PYTHON_VERSION=`python -V 2>&1 | awk '{print $2}' |cut -c 1-3`
      if [ -e /software/Linux/lib/python${PYTHON_VERSION} ]; then
        python /software/Linux/lib/python${PYTHON_VERSION}/site-packages/pymol/__init__.py $*
      else
        python2.5 /software/Linux/lib/python2.5/site-packages/pymol/__init__.py $*
      fi
      
After installing these and sourcing the setpaths.(c)sh script for cctbx, executing the pymol command should start a version of PyMOL that can use the cctbx modules.