Python

From ACENET
Jump to: navigation, search
Description
Python is a cross platform dynamic object-oriented programming language.
Modulefile
python
Documentation
Python homepage
Usage
$ module load python
$ module load gcc python/2.7.2
$ module load gcc python/3.4.1
You will need also to load the openmpi/gcc modulefile if you are going to use mpi4py.

Python Wheelhouse on Glacdyn/Glacdyn2

Similar to the Compute Canada Software Stack we have started a small Wheelhouse with Python wheels on the legacy ACENET machines. It is located at /usr/local/wheelhouse and can be activated by setting the PIP_CONFIG_FILE variable as shown below.

The following example creates a virtual python environment and installs a Cartopy wheel, that has been tested on our systems:

# load PIP configuration to activate wheelhouse:
export PIP_CONFIG_FILE=/usr/local/pip.conf

# load required modules:
module purge
module load  gcc/4.9.3  python/3.7.7  proj/8.2.1  geos/3.10.2

# create and activate venv
python3 -m venv ~/env_cartopy
source ~/env_cartopy/bin/activate

# install packages from wheelhouse (--no-index bypasses PyPI)
pip install --no-index -U pip wheel numpy scipy matplotlib ipython Cartopy==0.20.2

Python modules

SciPy Stack

Python module 2.6.2 2.7.2 2.7.10 3.4.x
Numpy 1.4.1 1.8.1 1.9.2 1.12.0
Scipy 0.7.2 0.14.0 0.16.0 0.18.1
Matplotlib 1.1.0 1.2.1 1.4.3 1.5.1
IPython 0.12 1.2.1 4.2.0 4.2.0
pandas -- 0.14.0 0.18.1 0.18.1
SymPy -- 0.7.5 -- 1.0
Nose 0.11.3 1.3.3 1.3.7 1.3.7

Other

Python module 2.6.2 2.7.2 2.7.10 3.4.1
Mercurial 2.11 2.11 -- --
NumericalPython 23.8.2 23.8.2 -- --
ScientificPython 2.8 2.8 -- --
Stsci_python 2.9 -- -- --
mpi4py 1.2.1 1.3 -- --
numexpr -- 2.1 -- --
netCDF4 -- 1.1.0 -- 1.2.4
PyTables -- 3.0.0 -- --
basemap -- 1.0.6 1.0.7 --
SCons -- 2.3.4 -- --
SIP -- 4.19.2 4.19.2 --
PyQt4 -- 4.12 4.12 --

If you need additional modules, we encourage you to installing them in your own filespace using one of the methods described below:

How to install own modules for Python 3 or Python 2.7

You can use the pip utility for easy installation. See the following page for details (do not forget the --user option), like so:

 $ pip install --user package-name

You can use easy_install, too.

How to install own modules for any version of Python

See the Python documentation for details:

  • Configure Python to find the new modules by adding the following line into your ~/.bashrc (replace python2.X with python2.6 or python2.7 depending on the version of python you are using):
$ export PYTHONPATH=$HOME/lib/python2.X/site-packages/:$PYTHONPATH

Then you can re-source your ~/.bashrc to get the changes into the current shell avoiding logging out:

$ source ~/.bashrc
  • Download and unpack the source files. (Here as an example we download the xlrd package.)
$ wget --no-check-certificate https://pypi.python.org/packages/source/x/xlrd/xlrd-0.9.3.tar.gz
$ tar xzf xlrd-0.9.3.tar.gz
$ cd xlrd-0.9.3/
  • Install a module specifying a prefix
$ python setup.py install --prefix=$HOME
  • If a module requires a fortran compiler then we strongly recommend to specify gfortran instead of g77 like so:
$ python setup.py build --fcompiler=gnu95 install --prefix=$HOME