Can't import ROOT in Python

I can’t import ROOT in IPython, it gives ‘ImportError: No module named ‘libPyROOT’’. I’ve installed ROOT through sudo apt-get install root-system.

locate libPyROOT.so gives

/usr/lib/python2.7/dist-packages/libPyROOT.so
/usr/lib/x86_64-linux-gnu/libPyROOT.so
/usr/lib/x86_64-linux-gnu/libPyROOT.so.5.34
/usr/lib/x86_64-linux-gnu/root5.34/libPyROOT.so
/usr/lib/x86_64-linux-gnu/root5.34/libPyROOT.so.5
/usr/lib/x86_64-linux-gnu/root5.34/libPyROOT.so.5.34
/usr/local/root/lib/libPyROOT.so

locate ROOT.py gives

/usr/lib/x86_64-linux-gnu/root5.34/ROOT.py
/usr/local/root/lib/ROOT.py
/usr/local/root/lib/ROOT.pyc
/usr/local/root/lib/ROOT.pyo
/usr/share/python-support/root/ROOT.py

I can’t figure, how to correctly set environment variables. Now they set to:

PYTHONPATH=/usr/share/python-support/root/
ROOTSYS=/usr/lib/x86_64-linux-gnu/root5.34/

Is there a way to set them correct?

Hi,

is your ipython version based on python3 or python2?

Danilo

Hi!

My Ipython version based on python3 (I installed id througn Anaconda).

Dmitry

Hi Dmitry,

you should install the python2 based and invoke it with ipython2.
Since you are interested in IPython, I’ll also point to the work we did for integrating root with notebooks (version 6 only): root.cern.ch/howtos#Notebooks

Cheers,
Danilo