Home | News | Documentation | Download

Cannot import ROOT on Python

Hi,

I cannot import ROOT on Python. Would you please teach me how to fix it?

I am using
macOS Catalina (v10.15.5)
python v3.7.7
ROOT v6.20/04
and my path is

rootver=6.20.04_1
export ROOTSYS=/usr/local/Cellar/root/${rootver}
export PYTHONPATH=$ROOTSYS/lib/root
source $ROOTSYS/bin/thisroot.sh

The log is as follows:

$ python3
Python 3.7.7 (default, Mar 10 2020, 15:43:27) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT

 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/Python] PyUnicode_InternFromString (no debug info)
[/usr/local/Cellar/root/6.20.04_1/lib/root/libPyROOT.so] PyROOT::CreatePyStrings() (no debug info)
[/usr/local/Cellar/root/6.20.04_1/lib/root/libPyROOT.so] PyInit_libPyROOT (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyImport_LoadDynamicModuleWithSpec (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _imp_create_dynamic (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyMethodDef_RawFastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyCFunction_FastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyFunction_FastCallKeywords (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] object_vacall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyObject_CallMethodIdObjArgs (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyImport_ImportModuleLevelObject (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyEval_EvalCode (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] builtin_exec (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyMethodDef_RawFastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyCFunction_FastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyFunction_FastCallKeywords (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] object_vacall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyObject_CallMethodIdObjArgs (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyImport_ImportModuleLevelObject (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyEval_EvalCode (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] builtin_exec (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyMethodDef_RawFastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyCFunction_FastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyFunction_FastCallKeywords (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] object_vacall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyObject_CallMethodIdObjArgs (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyImport_ImportModuleLevelObject (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyEval_EvalCode (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] run_mod (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyRun_InteractiveOneObjectEx (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyRun_InteractiveLoopFlags (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyRun_AnyFileExFlags (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] pymain_main (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _Py_UnixMain (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
[<unknown binary>] (no debug info)

Hi @Misaki_Mizmoto ,
and welcome to the ROOT forum!

There seems to be a python version mismatch somewhere: your Cellar mentions python 3.7 but the stacktrace also mentions /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/Python.

Could it be that you have to re-install ROOT via homebrew after an operating system update?

Also pinging @henryiii in case he has seen this problem before.
Cheers,
Enrico

1 Like

Thank you for your comments. I read the @henryiii 's post (ROOT Installs with Python 3.8.2), install python3.8, and can use pyROOT on python3.8.

Homebrew finished the 3.8 migration yesterday. python3 is now Python 3.8, and extra workarounds shouldn’t be required now.