Python fails to import ROOT

Hi experts,
I installed ROOT but it can’t be imported by python. The error is as following picture. May I ask how to fix the problem?


My first idea is:

  • Try python3

For more details, I would call on the pyroot expert @etejedor.


How did you install ROOT? Did you use conda?

If you didn’t, but you are using the conda Python, you may have incompatibility problems. You can try nevertheless to add the ROOT python modules to your environment, by running source $ROOTSYS/bin/, where ROOTSYS is the installation directory of ROOT, and then trying to import ROOT again.

thank you. I ran source $ROOTSYS/bin/, then imported ROOT, but it encouter error.
ImportError: dynamic module does not define module export function (PyInit_libPyROOT)

I have tried python3 and python2 but it can’t work.

after run source $ROOTSYS/bin/, I find ROOT can be imported by python2 but can’t python3. How can I make it work in python3, which is relevant to conda.

This is because your ROOT installation was built for Python2. If you want to use Python3, you will need to build ROOT with Python3 and thus have a separate installation.

In the next ROOT release (6.22) we will give the possibility to build ROOT for both Python2 and Python3, but unfortunately right now it is not possible.

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