Python is a general purpose, interpretive programming language. It is useful for both small-scale scripting tasks and large scale applications. There are numerous packages available for Python, including many ideally suited for scientific computing. If any Python packages are missing, we also provide instructions on how to install packages in your own directories. Python can be run interactively and in batch. It can be integrated with other programming languages, including C, C++, and Fortran.

Availability and Setup

Python 2.6.6 is the default version available on the SCC. You can also access newer versions of python (and python related packages) using the module system.

Running Python Interactively

Running Python interactively is quick and simple. To invoke Python, type:

scc1% python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

The Python command prompt, >>>, signifies that you have successfully started the Python environment. To close the Python session, enter exit()

>>> exit()

Running Python in Batch

Typically Python is run serially (that is using one processor), and you should follow the standard batch submission instructions found on our  Running Jobs documentation page to submit your Python jobs. In short, the best solution is to put your “python myscript.py” instruction in another file, a batch script, and then provide that script to qsub command.

Additional Help/Documentation

Python has the help() function, which prints the docstring (that is help information) for anything in python. For example the help information for the standard method len is:

>>> help(len)
Help on built-in function len in module __builtin__:

len(...)
    len(object) -> integer

    Return the number of items of a sequence or mapping.

>>>

Along with in depth online documentation, the Python website provides a comprehensive tutorial that has many examples. The Boston Python Meetup Group frequently presents a workshop and a series of tutorials (found in the Resources section of their workshop website) for users new to programming, and this is another good option for those wanting a gradual introduction.

We also have a set of our own tutorials on Python which we generally offer live three times a year but for which the slides are always available.