Problem with import ROOT lib

I am trying the last few days to do import the ROOT (PyROOT) lib in Python3.X and I could not find any solution on the Internet. I was trying to use both in ipython and PyCharm as well, without success, unfortunately. The error that I saw was “ImportError: No module named ROOT” or. Is there anyone in the group that he tried to it give any hint or direction or even better a guide to install it? I use Ubuntu 18.04 and the ROOT version that I have is 6.12. I hope that I did not forget anything.

Hi Zac,

Welcome to the forum!

I also had very hard times to install root with python3, I hope I can give you some hints…

First of all it would be helpful to understand how did you install root?
Did you:

  1. use package manager (apt-get) or pre-compiled binary package from the website
    or
  2. installed (compiled) root yourself using source files?

In the 1st case pyROOT is installed with your system default python which is probably python2.7 you can check that executing

python2
>>> import ROOT
>>>

which should work.

The solution to install pyROOT with new python3 which worked for me:

  1. Install python3 compiling source files with --enable-shared flag
  2. Install root compiling source files providing flag to the location of python3 -DPYTHON_EXECUTABLE=/path/to/desired/python3
    if I remember correcly.

You can check forum posts with the same problem, e.g.:
here
here

Also take note, at the Building ROOT from source - ROOT for pyROOT. It says that since v6.22 it is possible to do for two python versions simultaneously. So maybe it is easier if you use more recent versions of ROOT than 6.12

Maybe installing python3 from source is not necessary, you can try it out with your python3, but if it will complain that it needs “shared libraries”, then you need to compile python3 yourself as well…

I hope it helps,

cheers

Hello,

I’d recommend you install ROOT using conda, it’s probably the easiest option:

PS: Thank you @FoxWise for your post!

1 Like

Thanks…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.