Python
Python is programing language that continues to grow in popularity for scientific computing. It is very fast to write code in, but the software that results is much much slower than C or Fortran; one should be wary of doing too much compute-intensive work in Python.
At the time of writing, we have two versions of python installed on GPC - the default, version 2.6, and the newest in the 2.7 release series, 2.7.1, in the experimental modules.
Many optional packages are available for Python which greatly extend the language adding important new functionality. Those packages which are likely to be important to all of our users — eg, NumPy, SciPy, and Matplotlib are installed system-wide.
Python provides an easy way for users to install the libraries they need in their home directories rather than having them installed system-wide; there are so many potential optional packages for Python people could potentially want, we recommend users who want additional packages to proceed this way. This is almost certainly the easiest way to deal with the wide range of packages, ensure they're up to date, and ensure that users package choices don't conflict.
To install your own Python modules, follow the instructions below. Where the instructions say python2.X, type python2.6 or python2.7 depending on the version of python you are using.
- First, create a directory in your home directory, ${HOME}/lib/python2.X/site-packages, where the oackages will go.
- Next, in your .bashrc, *after* you module load python and in the "GPC" section, add the line export PYTHONPATH=${PYTHONPATH}:${HOME}/lib/python2.X/site-packages
- Re-load the modified .bashrc by typing source ~/.bashrc.
- Now, if it's a standard python package and instructions say that you can use easy_intall to install it,
- install with the following command: easy_install --prefix=${HOME} -O1 [packagename] where packagename is the name of the package you are installing.
- Continue doing this until all of the packages you need to install are successfully installed.
- If easy_install isn't an option for your package, and the installation instructions instead talk about downloading a file and using python setup.py install then instead:
- Download the relevant files
- You will probably have to uncompress and untar them: tar -xzvf packagename.tgz or tar -xjvf packagename.bz2.
- cd into the newly created directory, and run python setup.py install --prefix=${HOME}
- Now, the install process may have added some .egg files or directories to your path. For each .egg directory, add that to your python path as well in your .bashrc, in the same place as you had updated PYTHONPATH before: eg,
export PYTHONPATH=${PYTHONPATH}:${HOME}/lib/python2.7/site-packages:${HOME}/lib/python2.7/site-packages/packagename1-x.y.z-yy2.X.egg:${HOME}/lib/python2.X/site-packages/packagename2-a.b.c-py2.X.egg
- You should now be done! Now, re-source your .bashrc and test your new python modules.