ImportError: Failed to import libcppyy3_9. Please check that ROOT has been built for Python 3.9

Trying to run root with conda python environment in notebook. Initial error:

conda activate tf
python
import ROOT

raceback (most recent call last):
  File "/home/alpha/packages/root/root_install/lib/cppyy/__init__.py", line 60, in <module>
    importlib.import_module(libcppyy_mod_name)
  File "/home/alpha/anaconda3/envs/tf/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'libcppyy3_9'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alpha/packages/root/root_install/lib/ROOT/__init__.py", line 25, in <module>
    import cppyy
  File "/home/alpha/packages/root/root_install/lib/cppyy/__init__.py", line 62, in <module>
    raise ImportError(
ImportError: Failed to import libcppyy3_9. Please check that ROOT has been built for Python 3.9

however when I run:

(base) root-config --python3-version
3.9.19

it seems to say it was built with 3.9.

Though if I run that comand in my environment:

(tf) root-config --python3-version
bash: /home/alpha/anaconda3/envs/tf/lib/libtinfo.so.6: no version information available (required by bash)
3.9.19

i get that error before the print statement.

Here is how I compiled root, in base pointing to the conda env python:

cmake -DCMAKE_INSTALL_PREFIX=../root_install -DPYTHON_EXECUTABLE=/home/alpha/anaconda3/envs/tf/bin/python ../root_src

Any help appreciated, cheers.

PS: I have seen Python: No module named 'root', which is why I pointed at the exact python version I would like to use

Maybe I should add this, default python on the system is 3.11, I need 3.9 for tf and CUDA compatability stuff:

(base) alpha@alpha:~/packages/root/root_build$ python --version
Python 3.11.5
(base) alpha@alpha:~/packages/root/root_build$ conda activate tf
(tf) alpha@alpha:~/packages/root/root_build$ python --version
Python 3.9.19

Hi,

Are you then dealing with a Python version incompatibility?

Cheers,
D

I’m not sure what caused it since I thought pointing to python would be enough, I solved it by rebuilding root in the conda environment I plan to use, which seems to have worked.

1 Like

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