Failure to import ROOT after updating to python 3.11

Hi rooters,
After updating python to v3.11 I cannot use pyROOT anymore.
I have built root from source making the modifications suggested in the previous topic Code.h etc. have been moved in Python 3.11. The installation goes fine, and root correctly opens and works smoothly. However, I cannot import ROOT module from python code.
In python:

import ROOT

Here is the output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/username/Library/PhyTools/RootCern/v6_26_07_M1_cxx17_rebuild2/root_install/lib/ROOT/__init__.py", line 22, in <module>
    import cppyy
  File "/Users/username/Library/PhyTools/RootCern/v6_26_07_M1_cxx17_rebuild2/root_install/lib/cppyy/__init__.py", line 60, in <module>
    importlib.import_module(libcppyy_mod_name)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: type cppyy.CPPInstance has the Py_TPFLAGS_HAVE_GC flag but has no traverse function

ROOT Version: 6.26/08
Platform: macosxarm64
Compiler: clang-1400.0.29.102


Hello,

Fixes for Python3.11 are now in the 6.26 branch and in master, this means they will get released with 6.26/10 or 6.28/00.

In the meantime, if you build root from one of those branches, you shouldn’t see the error you reported.

Compiling the master branch solved the issue.
Thanks

1 Like

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