Python

Python is available on the system, with the typical packages such as Numpy and SciPy.  It is used by simply typing 'python' (this is version 2.6).  Python 2.7 is available with 'python27'.

If you need a lot of additional packages, or some built in enhancements, or the latest python and packages, installing your own copy might be best.  See below!

Anaconda Python (recommended option)

Anaconda Python is another option and lets users to install relevant packages that they need in their home directories easily. Anaconda python can be downloaded from https://www.continuum.io/downloads (choose Linux 64 bit). After downloading, simply run the installation script for setup in your home directory. 

You can then install many of the packages by the conda install command. For example

conda install numpy

conda install scipy

conda install mkl # Use Intel MKL libraries for numpy/scipy (recommended)

Make sure to include the Anaconda Python in your PATH environment variable. For example, include the following lines in your .bashrc, or .profile

export PATH="/home/anaconda/bin:$PATH"

 

Another option is Canopy, which includes quite a few extra packages (e.g. ipython) and provides you with a IDE.  If you want to useCanopy, first run the installer which will put it in your directory by

    bash  /sw/csc/canopy-1.5.2-full-rh5-64.sh

this will actually take several minutes to do, so go do something else for a moment while it works.  If you'll want to run jobs in the queue, you also need to set it up so that the Canopy python becomes your default - do this by

    ~/Canopy/canopy_cli setup ~/canopy --set-default

This will also take some time to process, so go get lunch while it runs. Once it is installed, you run Canopy (for the GUI) by

~/Canopy/canopy 

and if you've run the ' ~/Canopy/canopy_cli setup ~/canopy --set-default' then any time you use python, you'll be using the Canopy version (you can verify this by typing 'which python').

Jupyter Notebooks

If you like using Jupyter notebooks, you can do so on Knot (if using Anaconda). First, make sure that jupyter is installed (if not, install by conda install jupyter). Then, submit a job to the queue (one node only!) using the following job submission script

#!/bin/bash
#PBS -l nodes=1:ppn=1
#PBS -l walltime=01:00:00
#PBS -N Jupyter
#PBS -V

cd $PBS_O_WORKDIR # Goto job submission directory

## get tunneling info
XDG_RUNTIME_DIR=""
ipnport=$(shuf -i8000-9999 -n1)
ipnip=$(hostname -i)

## print tunneling instructions to jupyter.info
cat > jupyter.info << EOF
Paste ssh command in a terminal on local host (i.e., laptop)
-------------------------Copy-----------------------------------
ssh -N -L $ipnport:$ipnip:$ipnport $USER@knot.cnsi.ucsb.edu
Open this address in a browser on local host; see token below
------------------------------------------------------------
localhost:$ipnport                                      
EOF

## Launch jupyter server
jupyter-notebook --no-browser --port=$ipnport --ip=$ipnip

Now submit this script by qsub. 

After the job starts running, check the file jupyter.info, which will tell you how to ssh from your local computer. Copy and paste that line to your terminal and execute it. After this step, open your browser on your local computer and type the address

localhost:XXXX

where XXX is the ipnport printed in jupyter info. Now you can use Jupyter notebook on the compute nodes of Knot!

The above script will let you use Jupyter notebook for 1 hour and then terminate. If you need more time, increase the walltime.