Skip to content
Bart Verleye edited this page Feb 27, 2015 · 58 revisions

Table of Contents

Details

  • Homepage: http://www.python.org/
  • Versions available:
    • 2.7.3-gmpolf-1.4.8
    • 2.7.3-goolf-1.5.14
    • 2.7.3-goolf-1.5.14-QIIME
    • 2.7.3-ictce-5.4.0
    • 2.7.6-goolf-1.5.14
    • 2.7.8-goolf-1.5.14
    • 2.7.8-ictce-5.4.0
    • 3.4.1-goolf-1.5.14

Python is a programming language that lets you work more quickly and integrate your systems more effectively. - Homepage: http://python.org/

Usage

Activation of Python versions is done by using the module command, e.g.,

module load Python/2.7.8-goolf-1.5.14

This command will only work on one of the build nodes, or on the compute nodes if you use it in your SLURM script.

To deactivate the activated Python environment:

module unload Python/2.7.8-goolf-1.5.14

To see which Python packages are available:

pip freeze

or for Python 3,

pip3 freeze

For Python 2:

module load Python/2.7.8-goolf-1.5.14
virtualenv --system-site-packages ~/mypython

The output reads:

New python executable in /home/mfel395/mypython/bin/python Installing setuptools, pip...done.

For Python 3:

module load Python/3.4.1-goolf-1.5.14
pyvenv --system-site-packages ~/mypython

Unfortunately, pip is NOT installed into the virtual environment. Add it now

source ~/mypython/bin/activate
curl https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python

Not that under Python3 virtualenv is called pyvenv.

module load Python/2.7.8-goolf-1.5.14 )
source ~/mypython/bin/activate

Note how the system prompt changed to indicate that you are using your new environment You can now install additional packages into this environment as follows:

pip install cogent

To deactivate this environment:

 deactivate

Example SLURM jobs

example

Job description (download)
#!/bin/bash
#SBATCH -J PythonTest
#SBATCH -A uoa99999         # Project Account
#SBATCH --time=00:01:00     # Walltime
#SBATCH --mem-per-cpu=1G  # memory/cpu
#SBATCH --output=stdout.txt
#SBATCH --error=stderr.txt
 
# Load the Python module.
module load Python/2.7.8-goolf-1.5.14
 
# In addition, enable your virtual environment, if needed.
# Just delete or comment out the following line if you don't need your virtual environment.
source ~/mypython/bin/activate
 
# Do something with Python.
python -V 2>&1

Clone this wiki locally