How to Enable ROOT in python 2.7 in Scientific Linux 6.5

Scientific Linux 6.5 (x86_64) has the default python, version 2.6.6.
And now I install a new version python 2.7.7, without destroying python 2.6.6(system based, can’t be removed).
These two version of python all can be working well. the command python is linked to python2.6
Now I want to use PyROOT in python2.7, how can I do?

after this, no python is in the enabled features.

or just

the python2.6 is the default, PyROOT didn’t work in python2.7.

How to figure is out?

Thanks.

Hi,

two things: libdir must point to the location of libpython2.7.so, which is more likely ‘/usr/local/lib’. Second, make sure that python from $PATH is python2.7 (i.e. that /usr/local/bin comes before /urs/bin). In fact, that last should be sufficient to find libpython2.7.so and Python.h (no incdir/libdir necessary).

Cheers,
Wim

[quote=“wlav”]Hi,

two things: libdir must point to the location of libpython2.7.so, which is more likely ‘/usr/local/lib’. Second, make sure that python from $PATH is python2.7 (i.e. that /usr/local/bin comes before /urs/bin). In fact, that last should be sufficient to find libpython2.7.so and Python.h (no incdir/libdir necessary).

Cheers,
Wim[/quote]

Thanks for your reply.
But I have a question.
If I set python from $PATH is python2.7, I think my os will go wrong. Many processes in SL6.5 based on python, exactly the python2.6, not python2.7.

Or may I change it back after my installation of ROOT?

Hi,

you can also set PATH only for compiling ROOT, then reset it, and when running a ROOT session from python use explicitly ‘/usr/local/bin/python’.

Cheers,
Wim

Thanks to wlav’s reply. I figured my problem out.

[code]ln -s /usr/local/bin/python /usr/local/bin/python2.7

./configure --prefix=/usr/local --enable-python --with-python-incdir=/usr/local/include/python2.7/ --with-python-libdir=/usr/local/lib/

make

make install

rm /usr/local/bin/python
[/code]

set the environment variables

export ROOTSYS=/usr/local export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH export PATH=$ROOTSYS/bin:$PATH export PYTHONPATH=${ROOTSYS}"/lib/root:"${PYTHONPATH}

start root, a new problem come out.

to fix this problem login as root and make a file called root.conf in /etc/ld.so.conf.d/. Add this to the root.conf file:

then in the bash

After all of these, both versions of python enabled ROOT…

[code][cz@c ~]$ python
Python 2.6.6 (r266:84292, Nov 21 2013, 12:39:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
[/code]

[code][cz@c ~]$ python2.7
Python 2.7.7 (default, Jun 29 2014, 21:43:31)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
import rootpy
[/code]

Thank you again, wlav.

Post this here for a record.

Hi,

seems to me that libCore.so was not found, because LD_LIBRARY_PATH was set to:export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATHwhereas arguably it should have been (based on how you edit root.conf)export LD_LIBRARY_PATH=$ROOTSYS/lib/root:$LD_LIBRARY_PATH
Cheers,
Wim