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++, R, Fortran and others.
Availability and Setup
Python 2.6.6 is the default version available on the SCC. We recommend using the module system to access newer versions of python (and python related packages).
Running Python Interactively
Running Python interactively is quick and simple. Load the module for the version of python you want to use and run the command
scc1% module load python/2.7.13 scc1% python Python 2.7.13 (default, Feb 8 2017, 12:51:33) [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
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.
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
>>> 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.
Finally, as part of our RCS Online Code Examples section, we also have a number of Python code examples, both general including a “hello world” example and a set of examples from the tutorials we offer.