ROOT working only with python3

I have builded v6-08-00-patches on Manjaro, gcc 7.3.0. The python executable points by default to python3.
In python3 ROOT works, but not in python2

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/turra/root-sources/build-v6-08-00-patches/lib/ROOT.py", line 24, in <module>
    import cppyy
  File "/home/turra/root-sources/build-v6-08-00-patches/lib/cppyy.py", line 60, in <module>
    import libPyROOT as _backend
ImportError: dynamic module does not define init function (initlibPyROOT)

this is the same error if I try to install ROOT with the package manager.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/root/ROOT.py", line 24, in <module>
    import cppyy
  File "/usr/lib/root/cppyy.py", line 61, in <module>
    import libPyROOT as _backend
ImportError: dynamic module does not define init function (initlibPyROOT)

Dear @wiso,

It seems that, when you built ROOT, it found the Python3 installation and it built for Python3. If you want to use ROOT also with Python2, please make a separate build for Python2. The important point here is making sure that, when you build ROOT, it points to the right Python installation.

If you follow the instructions to build ROOT here:
https://root.cern.ch/building-root
you will see that there are a few Python-related variables (e.g. PYTHON_EXECUTABLE). Just make sure that those point to the Python2 installation.

Cheers,
Enric

ok, thanks. Isn’t possible to have it work for both?

Unfortunately not, currently ROOT needs to be built for a particular Python installation.

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