Python

Python is a high-level, multi-paradigm programming language that is both easy to learn and useful in a wide variety of applications.  Python has a large standard library as well as a large number of third-party extensions, most of which are completely free and open source. We highly recommend using the module to access Python, as we have added a lot of Python modules and tuned them to perform well on our systems.

Availability

Python is available on the Oakley and Glenn clusters.

Version Glenn Oakley
2.4.3 X*  
2.6.6   X*
2.7.1 X X

 

* - Default version

Usage

To run the Python interpreter using the default system-level Python installation, simply type the command “python”.  On Glenn, the default version used is 2.4.3.  On Oakley, the  default version used is 2.6.6.
 
Each system also has a Python 2.7.1 module.  To load this module, type one of the following commands depending on which system you are using.
 
On Glenn, type:
 
module load python-2.7.1
 
On Oakley, type:
 
module load python/2.7.1
 
After the module is loaded, you can run the interpreter by using the command
 
python
 

Installed modules

We have installed a number of Python modules and tuned them for optimal performance on our systems. Executing module help python will show you the current list.
 
setuptools, readline, bitarray, cloud, configobj, coverage, docutils, enstaller, epydoc, grin, html5lib, jinja2, nose, paramiko, ply, Crypto, pygarrayimage, pyglet, pygments, OpenSSL, pyparsing, pyproj, serial, dateutil, pytz, sphinx, sqlalchemy, xlrd, xlwt, scons, ldap, _mysql, numpy, scipy, pexpect, zope.interface, twisted, foolscap, wx, sip, PyQt4, matplotlib, zmq, IPython, PIL, reportlab, cython, numexpr, tables, argparse
 
Of special note is the fact that numpy and scipy have been compiled to use the optimized math libraries for each system (ACML on Glenn, MKL on Oakley) for best performance.
 
Due to architecture differences between our supercomputers, we recommend not installing your own packages in ~/.local. Instead, you should install them in some other directory and set $PYTHONPATH in your default environment. For more information about installing your own Python modules, please see our HOWTO.

Running Python Scripts in Batch

Python can technically be used in both interactive and non-interactive batch jobs, but you will most likely only want to run a Python script non-interactively.   To do this, you will need to write a batch submission script and a Python script.   
 
Below is a sample batch submission script and a simple “Hello World” program written in Python.
 
Example batch submission script, sample.job
 
#PBS –N hello
#PBS –l nodes=1:ppn=1
#PBS –l walltime=1:00:00
#PBS –j oe

module load python/2.7.1

python hello.py

#end of sample.job
 
Example Python script, hello.py:
 
import sys

hello = [“Hello”, “World”]

for i in hello:
    print i

sys.exit(0)

#end of hello.py
 
For more information about using the batch system, see Batch Processing at OSC.

See Also

HOWTO: Install your own python modules

Further reading

Extensive documentation of the Python programming language and software downloads can be found at the official Python website.  

 

Supercomputer: 
Service: 
Fields of Science: