OSX Mojave + ROOT v6-20-06 + Python 3


Please read tips for efficient and successful posting and posting code

ROOT Version: v6-20-06
Platform: MacOS Mojave 10.14.6 (x86_64)
Compiler: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Python: 3.8.2 installed with pyenv


Hello!
I am trying to compile the latest stable version of ROOT on macOS Mojave with Python 3 support.
Just to be clear, I am doing this because a younger student in our lab has a MacBook Air and she needs to work with me on a Python 3 project. I am using a macOS virtual machine to understand how to help her set the environment up. I personally find OSX not very developer-friendly and just a castrated version of Linux (and I am being kind) but this is off-topic.

I would happily have her use the precompiled binaries but they are only compatible with Python 2.
I checked that I can install the precompiled binaries without issues and use them with the system Python version 2.7.16. However (even if it is not my final goal), if I try the precompiled binaries with Python 2.7.18 installed with pyenv, I get this error:

~ neo$ python Python 2.7.18 (default, Jun 15 2020, 20:54:34) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT Fatal Python error: PyThreadState_Get: no current thread Abort trap: 6

I have then tried to compile ROOT with Python 3.8.2 installed by pyenv and the compile seems to go smoothly but when I try to import ROOT hell breaks free:

$ python3
Python 3.8.2 (default, Jun 15 2020, 18:35:20)
[Clang 10.0.1 (clang-1001.0.46.4)] 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)
[] (no debug info)
[/Users/neo/ROOT/current/lib/libPyROOT.so] PyUnicode_InternFromString /var/folders/xk/88q4ph593qg8d0yxs33vdg0w0000gn/T/python-build.20200615182848.992/Python-3.8.2/Objects/unicodeobject.c:15323
[/Users/neo/ROOT/current/lib/libPyROOT.so] PyROOT::CreatePyStrings() (no debug info)
[/Users/neo/ROOT/current/lib/libPyROOT.so] PyInit_libPyROOT (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyImport_LoadDynamicModuleWithSpec (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _imp_create_dynamic (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] cfunction_vectorcall_FASTCALL (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyVectorcall_Call (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalCodeWithName (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyFunction_Vectorcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] object_vacall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyObject_CallMethodIdObjArgs (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyImport_ImportModuleLevelObject (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalCodeWithName (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyEval_EvalCode (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] builtin_exec (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] cfunction_vectorcall_FASTCALL (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyVectorcall_Call (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalCodeWithName (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyFunction_Vectorcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] object_vacall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyObject_CallMethodIdObjArgs (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyImport_ImportModuleLevelObject (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalCodeWithName (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyEval_EvalCode (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] builtin_exec (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] cfunction_vectorcall_FASTCALL (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyVectorcall_Call (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalCodeWithName (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyFunction_Vectorcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] call_function (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] function_code_fastcall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] object_vacall (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyObject_CallMethodIdObjArgs (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyImport_ImportModuleLevelObject (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalFrameDefault (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] _PyEval_EvalCodeWithName (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyEval_EvalCode (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyRun_InteractiveOneObjectEx (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyRun_InteractiveLoopFlags (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] PyRun_AnyFileExFlags (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] Py_RunMain (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] pymain_main (no debug info)
[/Users/neo/.pyenv/versions/3.8.2/bin/python3] Py_BytesMain (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)

I have also tried to install Python using brew but I could not even compile ROOT in that way. To compile ROOT I use these commands:

pyenv shell 3.8.2
mkdir -p ROOT
cd ROOT
mkdir build
mkdir v6-20-06
git clone GitHub - root-project/root: The official repository for ROOT: analyzing, storing and visualizing big data, scientifically source
cd source
git checkout -b v6-20-06 v6-20-06
cd …/build
cmake -Dpython=On -Dminuit2=On -DCMAKE_INSTALL_PREFIX=${HOME}/ROOT/v6-20-06 -DPYTHON_EXECUTABLE=$(command -v python3) …/sources

In conclusion, my question is:
What is the best way to compile ROOT with Python 3 support on MacOS Mojave?

You could maybe try with a more recent version of ROOT, and I think @etejedor can give more details about the supported versions of Python on different platforms

I tried the latest version listed here: https://root.cern/downloading-root
Which version do you recommend?

Oh sorry, I was sure 6.22.00 was out already. But still, I think 6.20.06 should work. @etejedor can confirm

Hi,

The steps you followed to compile ROOT seem ok, I don’t know what could be going on with the pyenv Python (I have used pyenv Pythons in the past without problem).

We have nightly builds on MacOS 10.14, and we build with Python3.8.2. I just checked and the Python we use there was installed from a .pkg file. Perhaps you could try the same?

As you already did, you need to include the -DPYTHON_EXECUTABLE option to point to the Python3 binary. From that binary, it should also find the Python headers and libraries (which are necessary to build ROOT).

On a side note, we will soon release 6.22 and we will have ROOT binaries for both Python2 and Python3, but probably not for all platforms (I still can’t say if one of them will be yours).

1 Like

Have you tried brew install root? That will give you 6.20.04. Just remember that you may have to export PYTHONPATH=$(root-config --libdir) to be able to call import ROOT and make sure to use Homebrew’s Python.

1 Like

I have not tried with brew but I tried with Anaconda and could install Python 3 and ROOT (with some effort). But thank you all anyway for the suggestions, it is always good to have many ways to try.

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