Installing PyROOT with multiple versions of Python

Hi,

I’m attempting to install ROOT with multiple versions of python on a university research computing cluster. The system’s administrators already have 2 versions of python installed in a common directory (v2.6 and v3.0). I have installed my own version of python to use with ROOT. I first attempted to do this with ROOT v5.28 and python v2.7 and attempted the following:
To build python:
./configure --enable-shared --prefix=/software_directory/python_usr_2.7
gmake
gmake altinstall
To build root:
./configure linuxx8664gcc --enable-python
–enable-roofit
–with-python-libdir=/software_directory/python_usr_2.7/lib
–with-python-incdir=/software_directory/python_usr_2.7/include/python2.7

and that’s where I get my problem… if I look in my config.log I see:

Checking for Python.h …
Checking in directory /software_directory/python_usr_2.7/include/python2.7
Checking for Python.h in directory /software_directory/python_usr_2.7/include/python2.7
/software_directory/python_usr_2.7/include/python2.7/Python.h is read-able

Checking for python2.6, libpython2.6, libpython, python, or Python …
libraries to check for: python2.6.so python2.6.sl python2.6.dylib python2.6.dll.a libpython2.6.so libpython2.6.sl libpython2.6.dylib libpython2.6.dll.a libpython.so libpython.sl libpython.dylib libpython.dll.a python.so python.sl python.dylib python.dll.a Python.so Python.sl Python.dylib Python.dll.a python2.6.a python2.6.lib python2.6 libpython2.6.a libpython2.6.lib libpython2.6 libpython.a libpython.lib libpython python.a python.lib python Python.a Python.lib Python

Checking in directories /software_directory/python_usr_2.7/lib64 /software_directory/python_usr_2.7/lib for python2.6.so python2.6.sl python2.6.dylib python2.6.dll.a libpython2.6.so libpython2.6.sl libpython2.6.dylib libpython2.6.dll.a libpython.so libpython.sl libpython.dylib libpython.dll.a python.so python.sl python.dylib python.dll.a Python.so Python.sl Python.dylib Python.dll.a python2.6.a python2.6.lib python2.6 libpython2.6.a libpython2.6.lib libpython2.6 libpython.a libpython.lib libpython python.a python.lib python Python.a Python.lib Python

Checking for library python2.6.so in directory /software_directory/python_usr_2.7/lib
Checking /software_directory/python_usr_2.7/lib/python2.6.so
python2.6.so not found in /software_directory/python_usr_2.7/lib

And there is my problem… even though I am using python v2.7.x ROOT is looking for python v2.6.x associated library files, and thus can’t find them.
And if ROOT would look for python2.7.so it would find it in /software_directory/python_usr_2.7/lib

And if I continue and do >make to ROOT and try to start up PyROOT it errors (as expected) and says it can’t find libPyROOT:

error in TUnixSystem::DynamicPathName: libPyROOT[.so | .sl | .dl | .a | .dll] does not exist in /software_directory/root-5.28/lib:/software_directory/root-5.28/lib:/software_directory/python_usr_2.7/lib:/software_directory/python_usr_2.7/lib::.:/software_directory/root-5.28/lib::/software_directory/root-5.28/cint/cint/stl
(int)(-1)

It’s like the python v2.6 that the system’s administrators have already on the system is over-riding my version of python at points.

And when I try the same exact thing but with Python v2.6 (rather than v2.7) everything compiles fine and PyROOT works (which is what I expect since I know no matter what version of Python I tell ROOT to use it still looks for the PyROOT libraries associated w/version 2.6).

Any suggestions on what I can do?

Thanks!

~Jacquie

Jacquie,

the script picks up the python version from the python executable available through PATH. Hence, when installing for a different python installation, simply add it to PATH first. Myself, for testing different versions, I simply symlink the desired python from the intended $ROOTSYS/bin and add that to PATH. That way, I only need to move that link around.

Cheers,
Wim

Hi Wim,

I have done that (I should have mentioned that in my previous post). I set the following env variables before configuring python and before configuring root (just to be double sure):

setenv PYTHONDIR $SOFTDIR/python_usr_2.6
setenv LD_LIBRARY_PATH $PYTHONDIR/lib:$LD_LIBRARY_PATH
setenv ROOTSYS ${SOFTDIR}/root-5.28
setenv PATH $ROOTSYS/bin:$PATH
setenv LD_LIBRARY_PATH $ROOTSYS/lib:$PYTHONDIR/lib:$LD_LIBRARY_PATH
setenv PYTHONPATH
setenv PYTHONPATH $ROOTSYS/lib:$PYTHONPATH

~Jacquie

correction:

I did:

setenv PYTHONDIR $SOFTDIR/python_usr_2.7
setenv LD_LIBRARY_PATH $PYTHONDIR/lib:$LD_LIBRARY_PATH
setenv ROOTSYS ${SOFTDIR}/root-5.28
setenv PATH $ROOTSYS/bin:$PATH
setenv LD_LIBRARY_PATH $ROOTSYS/lib:$PYTHONDIR/lib:$LD_LIBRARY_PATH
setenv PYTHONPATH
setenv PYTHONPATH $ROOTSYS/lib:$PYTHONPATH

(for when I try to use python v2.7)

Jacquie,

so from that I see $PYTHONDIR/lib added to LD_LIBRARY_PATH (needed to locate libpythonx.y.so at runtime, but I don’t think it’s needed for build time), but I’m missing $PYTHONDIR/bin added to PATH? That’d be needed for both build and runtime.

Cheers,
Wim

Hi Wim,

I added PYTHONDIR/bin to both my PATH and PYTHONPATH:

setenv PYTHONDIR ${SOFTDIR}/python_usr_2.7
setenv LD_LIBRARY_PATH ${PYTHONDIR}/lib:$LD_LIBRARY_PATH
setenv ROOTSYS ${SOFTDIR}/root-5.28
setenv PATH ${ROOTSYS}/bin:$PATH
setenv PATH ${PYTHONDIR}/bin:$PATH
setenv LD_LIBRARY_PATH ${ROOTSYS}/lib:${PYTHONDIR}/lib:$LD_LIBRARY_PATH
setenv PYTHONPATH
setenv PYTHONPATH ${ROOTSYS}/lib:$PYTHONPATH
setenv PYTHONPATH ${PYTHONDIR}/bin:$PYTHONPATH

I then reconfigured and remade Python (v2.7.1) and ROOT (v5.28) … and I’m still getting the same issue, that when I configure ROOT it is looking for python2.6.so instead of python2.7.so

Jacquie,

but is the version of python after adding $PYTHONDIR/bin to PATH the correct one? I.e. is python --version giving 2.7 at that point? Also, there’s no need to add $PYTHONDIR/bin to PYTHONPATH (although it should not matter).

Cheers,
Wim

Hi Wim,

After adding $PYTHONDIR/bin to PATH if I type ‘python’ at the prompt it opens v2.6.2 (the version installed by the system’s administrators; not my own).

I have to create an alias command for it to open my own:

alias python ‘/SOFTDIR/python_usr_2.7/bin/python2.7’

And I had tried it with and without adding $PYTHONDIR/bin to PYTHONPATH, so that didn’t cause any errors in my latest attempt - but I will remove it in the future.

~Jacquie

Jacquie,

an alias is not going to work with the configure script (it’d live in the current shell only). But does this mean that $PYTHONDIR/bin only contains python2.7, not python? If so, a symlink from python -> python2.7 would be needed (also for convenience down the road).

Cheers,
Wim

Hey Wim,

In my $PYTHONDIR/bin there wasn’t a python (only a python2.7). So I added a symlink from python -> python2.7 and now everything compiles great and PyROOT is working.

Thanks for your help!

~Jacquie

thnx for the help