Problem with import ROOT lib

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