Home | News | Documentation | Download

Problem with import ROOT


#1

ROOT Version: 6.14
Platform: MacOS High Sierra
Compiler: Not Provided


Hi everyone. I have problems with importing ROOT when computing on python (both 2.7 and 3.6.6). The error is as follows (without source .bashrc):

import ROOT

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ModuleNotFoundError: No module named 'ROOT'

But when I do source .bashrc I get the following:

import ROOT

*** Break *** segmentation violation

[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)

[<unknown binary>] (no debug info)

[/Users/boldrinicoder/anaconda3/lib/libpython3.6m.dylib] PyUnicode_InternFromString (no debug info)

[/Users/boldrinicoder/buildroot/lib/libPyROOT.so] PyROOT::CreatePyStrings() /Users/boldrinicoder/root/root-6.14.06 2/bindings/pyroot/src/PyStrings.cxx:64

[/Users/boldrinicoder/buildroot/lib/libPyROOT.so] PyInit_libPyROOT /Users/boldrinicoder/root/root-6.14.06 2/bindings/pyroot/src/RootModule.cxx:848

[/Users/boldrinicoder/anaconda3/bin/python] _PyImport_LoadDynamicModuleWithSpec (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _imp_create_dynamic (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyCFunction_Call (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalCodeWithName (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyFunction_FastCallDict (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyObject_FastCallDict (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyObject_CallMethodIdObjArgs (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyImport_ImportModuleLevelObject (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalCodeWithName (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] builtin_exec (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyCFunction_Call (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalCodeWithName (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyFunction_FastCallDict (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyObject_FastCallDict (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyObject_CallMethodIdObjArgs (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyImport_ImportModuleLevelObject (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalCodeWithName (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] builtin_exec (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyCFunction_Call (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalCodeWithName (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] fast_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] call_function (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyFunction_FastCallDict (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyObject_FastCallDict (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyObject_CallMethodIdObjArgs (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyImport_ImportModuleLevelObject (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalFrameDefault (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] _PyEval_EvalCodeWithName (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyRun_InteractiveOneObjectEx (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyRun_InteractiveLoopFlags (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] PyRun_AnyFileExFlags (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] Py_Main (no debug info)

[/Users/boldrinicoder/anaconda3/bin/python] main (no debug info)

[/usr/lib/system/libdyld.dylib] start (no debug info)

[<unknown binary>] (no debug info)

This is what I wrote in the bashrc:

source /Users/boldrinicoder/buildroot/bin/thisroot.sh

export PYTHONDIR=/Users/boldrinicoder/anaconda3/bin/python

export PYTHONPATH=$ROOTSYS:$PYTHONDIR:/lib:/Users/boldrinicoder/anaconda3/bin/python:/lib:$PYTHONPATH

So I think the problem is in here. I installed ROOT via the root build description in the root building page. I can’t figure out what’s the problem


#2

The error you get is from trying to use ROOT with anaconda Python instead of the Python it was built for. You cannot use ROOT with a different Python than it was compiled against. If you want to use ROOT with anaconda Python, you must use anaconda’s GCC to compile ROOT and configure ROOT with cmake -DPYTHON_EXECUTABLE=.../anaconda3/bin/python (i.e. full path to Python from anaconda).


#3

Tried to recompile everything. (I just deleted the folder for root and buildroot then did everything again ad described here https://root.cern.ch/building-root) but at the point of

cmake path/to/source

I instead typed:

cmake -DPYTHON_EXECUTABLE=/Users/boldrinicoder/anaconda3/bin/python

As I get:

Giacomos-MBP:~ boldrinicoder$ which python
/Users/boldrinicoder/anaconda3/bin/python

I don’t know how to "use anaconda GCC to compile ROOT… I found this post https://github.com/AGerrety/ROOT6PYTHON3 but import ROOT still gives the same set fault both on python 3.6.6 and 2.7… Am I missing something?


#4

Please post here the equivalent of the pasted lines shown below for your setup (output of the CMake configuration command), and also try with the master branch if you can (I put a check for consistency of Python versions there). In summary, you have to make sure that the Python interpreter and libraries match and are ABI-compatible with the C++ compiler you are using for ROOT. If PythonInterp and PythonLibs show different versions, then you need to fix the configuration.

-- Looking for python
-- Found PythonInterp: /usr/bin/python (found version "3.5.5") 
-- Found PythonLibs: /usr/lib64/libpython3.5m.so (found version "3.5.5") 

#5

Solved uninstalling anaconda and compiling root with your cmake -DPYTHON_EXECUTABLE=… and now everything works fine. Thank you