Compiling ROOT against multiple versions of python

Currently, I am trying to upgrade some of my programs from python2 to python3. When compiling ROOT, I can select which version of python to compile against. However, whichever one that I choose, I get a rather nasty ImportError when trying to import it with the other version of python.

[code]Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
Traceback (most recent call last):
File “”, line 1, in
File “/mnt/misc/sw/x86_64/Debian/8/root/gnu/5.34.32/lib/”, line 103, in
import libPyROOT as _root
ImportError: dynamic module does not define init function (PyInit_libPyROOT)


I want to recompile only the python-specific parts of ROOT, so that I can have two separate versions of, and can choose which one to import. How do I compile ROOT against multiple versions of python, so that will be generated for each version of python?

Dear Mere,

For the time being this is not possible. When building ROOT you make a choice of what version of Python, therefore if you want to have libPyROOT for both versions you will need to have two installations.
It is in our plans to be able to build PyROOT separately from ROOT (as a Python extension module) and be able to chose which ROOT and which Python. But this is not yet there.


doesn’t the ‘make clean-pyroot’ work anymore? With that, move to some “safe” location, clean-pyroot, reconfigure for new python, then rebuild. The configuration will pick up some core stuff, but is way faster than rebuilding all of ROOT.