Python is a high level programming language that aims to combine remarkable power with very clear syntax. Its success in these areas has led to strong adoption by the scientific community, resulting in numerous math, physics, chemistry, and biology libraries being contributed from the community of users.
Software Updates and Version Consistency
MSI maintains installations of Python optimized for scientific and development use on all MSI computational resources. These include additional tools and libraries such as IPython, SciPy, NumPy, BioPython, Django, and many others. MSI supports the Enthought Python Distribution/Canopy and Continuum Analytics Anaconda Python as well as the PyPy alternative Python implementation.
To enable our default version of Python 2.7 (currently a version of the Enthought distribution), type
module load python
To enable our recommend version of Python 3 (currently a version of the Anaconda distribution), type
module load python3
Several other versions of Python are available, but the versions may be different on different platforms. To list all versions of Python available on the machine, type
module avail python
Assistance with Python programming is available by contacting firstname.lastname@example.org.
The following information applies to all supported versions of Python. Additional information relevant to a particular environment can be found at the following links:
- python, python-epd: Enthought Python Distribution
- python3, anaconda: Anaconda Python
- python-pypy: PyPy Python
In the examples below we use module load python. They will also work if you select a specific environment version (python3/3.4) or implementation (python-epd, python-pypy). Loading a module for Python will make that Python environment your default for all Python-related commands.
To run Python interactively in a Linux environment run the commands:
module load python ipython
If you would like to run a Python script, myscript.py, use the following command:
module load python python myscript.py
Programs can be submitted to a queue using PBS script such as the one below:
#PBS -l nodes=1:ppn=1,mem=1gb,walltime=4:00:00 #PBS -m abe cd /location/of/the/script module load python-epd python myscript.py
Our recommended environments for Python 2.7 (module load python) and Python 3.4 (module load python3) include a wide variety of useful scientific, mathematical, and programming packages already installed. You can usually determine if a package is installed by attempting to import its module from Python:
module load python ipython > import somepackage
If this succeeds without printing an error, the package is installed and ready to use. Otherwise, in most cases we recommend that you use the provided tools to install a local copy of the package in your home directory.
The simplest way to accomplish this is to use pip to install from the Python Package Index. Once you have determined the PyPI name of the package you want, you can install or upgrade the package with the commands:
module load python pip install --user --upgrade packagename
For more complex installations you may want to create a Python virtual environment in your home directory. The commands to do so are not the same across all Python environments. Please see the software documentation page for the environment you are using for instructions.