Import ROOT in python


I face a problem when I import ROOT in python.

from ROOT import * 

And, the error is

ImportError: Failed to import libcppyy3_8. Please check that ROOT has been built for Python 3.8

Is there a new version of ROOT I can update?
Or, maybe I miss something.

Thank you.
Jhih Jia

_ROOT Version: 6.22/07
_Platform: Ubuntu 16.04.5 LTS
_Compiler: python 3.8.6


According to the error message, it looks like you are importing ROOT with Python3.8 but your ROOT installation was not built for Python3.8.

Try running:

root-config --python-version

To know which Python version your ROOT was built with.


thank you for your reply.

After running that, it gives me:


So, if I want to use ROOT with python 3.8, I need to rebuilt it?
I don’t know a lot of things in program, so maybe it is a stupid question.

I want to do that because I need to use xgboost to run machine learning. I followed the steps of official website of xgboost to download it to lab’s computer, but the version is too old. Then I use nix to build for a new version.

Yes, or alternatively you can run your script with Python3.5.

Here you can find instructions on how to build from source and pick a particular Python version:

Thanks a lot.

I will try it!!