Using PyROOT on lxplus
Install ROOT following the instructions on this page. In order to use pyroot on LxPlus, there are further adjustments to do.
First check the installation path of your python executable:
which python
Then export $PYTHONDIR as the path the folder above the bin and lib folder. For example:
echo "export PYTHONDIR=/afs/cern.ch/sw/lcg/external/Python/2.7.3/x86_64-slc6-gcc48-opt" >> $HOME/.bashrc
Also update $PYTHONPATH and $LD_LIBRARY_PATH:
echo "export PYTHONPATH=$PYTHONPATH:$ROOTSYS/lib" >> $HOME/.bashrc
echo "export LD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$LD_LIBRARY_PATH:/opt/rh/python27/root/usr/lib64" >> $HOME/.bashrc
Using other Python modules
To use external modules such as numpy or scipy it is almost always necessary to install them in your own afs workspace. The following example installs numpy 1.8.2 (remember to check the latest version on SourceForge!).
mkdir my-numpy
cd my-numpy
wget http://switch.dl.sourceforge.net/project/numpy/NumPy/1.8.2/numpy-1.8.2.tar.gz
tar -xzf numpy-1.8.2.tar.gz
mkdir INSTALL
cd numpy-1.8.2
python setup.py install --prefix=$HOME/my-numpy/INSTALL
(Numpy needs to be compiled, as it includes some C++ code.)
To use the compiled module, either do
import sys
sys.path.append('path/to/your/home/my-numpy/INSTALL/lib/python2.7/site-packages')
in your python scripts, or copy the entire folder $HOME/my-numpy/INSTALL/lib/python2.7/site-packages/numpy (or, in other cases, the folder containing __init__.py) into your working directory, or add to $PYTHONPATH:
export PYTHONPATH=path/to/your/home/my-numpy/INSTALL/lib/python2.7/site-packages:$PYTHONPATH
Note that adding the install directory to $PYTHONPATH
might be needed even before installing the package, depending on the package and the python distribution.