Home | News | Documentation | Download

Can not import root in python

Hello,

I have a problem with importing root6.22.06 in python2.7.18. and I hoped that you could help me. I’m using Centos 7.

Python is installed and ROOT as well but as soon as I want to import ROOT there is an import error that there is no module named ROOT.

Thanks in advance and kind regards,
Lilian

Hello,

Please try running source $ROOTSYS/bin/thisroot.sh, where ROOTSYS is the directory where ROOT is installed, and then try again to open Python and import ROOT.

Hi!
Thanks for your response.
I installed ROOT via EPEL (Centos):

$ yum install epel-release
$ yum install root

The command ‘whereis thisroot.sh’ delivers no location.
‘whereis root’ tells me /usr/bin/root.exe

Hi @lilino,

I think that on Fedora/CentOS, an additional package is required for PyROOT support. I think that for Python-2.7, the package should be named python2-root. Therefore, you can try:

$ sudo yum install python2-root

Let us know if that fixes your issue.

Cheers,
J.

Hi again,
I installed python2-root, but still can’t import ROOT or find thisroot.sh.
Do you have any other ideas what to try?
Thanks and cheers,
L.

Hi @lilino,

Could you confirm that you are running Python-2.7, i.e., $ python --version. EPEL provides different packages depending on the Python version. Also, could you confirm that after installing the package the directories cppyy, cppyy_backend, and ROOT can be found under /usr/lib64/python2.7/site-packages/?

Finally, could you copy here the specific error that you are getting when you try to import ROOT?

Cheers,
J.