Windows10 ImportError: Failed to import libcppyy3_7. Please check that ROOT has been built for Python 3.7

I have ROOT 6.24.00 installed on Windows 10 through Anaconda3 complied against VS2019 and python 3.7.9. I get the above error

ImportError: Failed to import libcppyy3_7. Please check that ROOT has been built for Python 3.7

when I try and import ROOT in Spyder5. I can’t call root from the anaconda prompt at all. I can check

root-config --python-version

from the anaconda prompt and it says 3.7.9. Anyone have any thoughts? I’m stumped.

Hi @Kittyk123,

I can only suspect that either libcppyy3_7.dll or libcppyy_backend3_7.dll cannot be found in the library search path. However, I am sure that @etejedor can provide a more detailed answer.

Cheers,
J.

Hi,

That should not happen when installing via conda, I’ll check with the package maintainer and get back to you.

The ROOT conda package maintainer informed me that there are no Windows binaries for ROOT in conda-forge as 32-bit Python isn’t supported.

Is it possible that you are using a ROOT installation that you built yourself?

Yeah, I built root myself following the Github instructions to make sure it was complied against the right Visual Studio (I have 3 versions on my computer) and my version of Python. I question if the problem is my Anaconda installation since I have had previous issues calling Python from MATLAB and vice versa, but I worry about changing my Anaconda installation because I have projects for another lab I work in on my computer as well.

Hi @Kittyk123,

If you built root yourself, some environment variables might not have the correct value (namely search paths). Try running the thisroot.bat script included on your build/install directory on a cmd.exe session. Reuse the same cmd.exe session to start the python interpreter and issue:

import ROOT

Let us know if that workarounds your problem.

Cheers,
J.