Cannot compile ROOT from source, Looking for python error make

Hello everyone.
In an attempt to enable RooFit i deleted my already working ROOT to build a new one with the option -Droofit=ON. turns out that now make cannot find any python interpreter in my system but keeps finding 1.4 (which I do not have or I did not know) even if I tell it to search for python 2.7 (I have a Mac so that is default) or for my home-brew python 3.6.5. I really do not know what to do.
Here is what I tried now:

rm -rf buildroot //if present
mkdir buildroot
cd buildroot
cmake -DPYTHON_EXECUTABLE=$/usr/local/bin/python3 /Users/boldrinicoder/Downloads/root

This is the output:

-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.20.1 (Apple Git-117)") 
-- ROOT default compression algorithm: zlib
-- Performing Test HAS_CXX11
-- Performing Test HAS_CXX11 - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found a Mac OS X System 10.14
-- Found a 64bit system
-- Found LLVM compiler collection
-- Performing Test GLIBCXX_USE_CXX11_ABI
-- Performing Test GLIBCXX_USE_CXX11_ABI - Failed
-- ROOT Platform: macosx
-- ROOT Architecture: macosx64
-- Build Type: RelWithDebInfo
-- Compiler Flags:  -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11 -stdlib=libc++ 
-- Looking for ZLib
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.11") 
-- Building freetype version 2.6.1 included in ROOT itself
-- Looking for PCRE
-- Found PCRE: /usr/local/include  
-- Looking for LZMA
-- Found LZMA includes at /usr/local/include
-- Found LZMA library at /usr/local/lib/liblzma.dylib
-- Looking for xxHash
-- Could NOT find xxHash (missing: xxHash_LIBRARY xxHash_INCLUDE_DIR) 
-- xxHash not found. Switching on builtin_xxhash option
-- Looking for LZ4
-- Found LZ4: /usr/local/lib/liblz4.dylib (found version "1.8.3") 
-- Could NOT find GIF (missing: GIF_LIBRARY GIF_INCLUDE_DIR) 
-- Found TIFF: /usr/local/lib/libtiff.dylib (found version "4.0.10") 
-- Found PNG: /usr/local/lib/libpng.dylib (found version "1.6.36") 
-- Found JPEG: /usr/local/lib/libjpeg.dylib (found version "90") 
-- Building AfterImage library included in ROOT itself
-- Looking for GSL
-- Found GSL: /usr/local/Cellar/gsl/2.5/include (found suitable version "2.5", minimum required is "1.10") 
-- Looking for python
-- Found PythonInterp: /Users/boldrinicoder/buildroot/$/usr/local/bin/python3 (found version "1.4") 
-- Found PythonLibs: /usr/local/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib (found version "3.6.5") 
-- Looking for numpy (python package)
-- TMVA: numpy not found for python /Users/boldrinicoder/buildroot/$/usr/local/bin/python3. Switching off tmva-pymva option
CMake Error at cmake/modules/SearchInstalledSoftware.cmake:480 (message):
  Version mismatch between Python interpreter (1.4) and libraries (3.6.5).

  ROOT cannot work with this configuration.  Please specify only
  PYTHON_EXECUTABLE to CMake with an absolute path to ensure matching
  versions are found.
Call Stack (most recent call first):
  CMakeLists.txt:150 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/boldrinicoder/buildroot/CMakeFiles/CMakeOutput.log".
See also "/Users/boldrinicoder/buildroot/CMakeFiles/CMakeError.log".

The same also happened if I try the following:

cmake -DPYTHON_LIBRARY=$(python-config --prefix)/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python2.7 -DPYTHON_EXECUTABLE=$/usr/bin/python /Users/boldrinicoder/Downloads/root/

With error:

-- ROOT default compression algorithm: zlib
-- Found a Mac OS X System 10.14
-- Found a 64bit system
-- Found LLVM compiler collection
-- ROOT Platform: macosx
-- ROOT Architecture: macosx64
-- Build Type: RelWithDebInfo
-- Compiler Flags:  -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11 -stdlib=libc++ 
-- Looking for ZLib
-- Building freetype version 2.6.1 included in ROOT itself
-- Looking for PCRE
-- Looking for LZMA
-- Found LZMA includes at /usr/local/include
-- Found LZMA library at /usr/local/lib/liblzma.dylib
-- Looking for LZ4
-- Could NOT find GIF (missing: GIF_LIBRARY GIF_INCLUDE_DIR) 
-- Building AfterImage library included in ROOT itself
-- Looking for GSL
-- Looking for python
-- Found PythonInterp: /Users/boldrinicoder/buildroot/$/usr/bin/python (found version "1.4") 
-- Found PythonLibs: /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found version "2.7.15") 
CMake Error at cmake/modules/SearchInstalledSoftware.cmake:480 (message):
  Version mismatch between Python interpreter (1.4) and libraries (2.7.15).

  ROOT cannot work with this configuration.  Please specify only
  PYTHON_EXECUTABLE to CMake with an absolute path to ensure matching
  versions are found.
Call Stack (most recent call first):
  CMakeLists.txt:150 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/boldrinicoder/buildroot/CMakeFiles/CMakeOutput.log".
See also "/Users/boldrinicoder/buildroot/CMakeFiles/CMakeError.log".

In case you were wondering here are my pythons:

BoldriniCoder:~ boldrinicoder$ which python
/usr/bin/python
BoldriniCoder:~ boldrinicoder$ which python3
/usr/local/bin/python3
BoldriniCoder:~ boldrinicoder$ type -a python
python is /usr/bin/python
BoldriniCoder:~ boldrinicoder$ type -a python3
python3 is /usr/local/bin/python3
BoldriniCoder:~ boldrinicoder$ /usr/bin/python --version
Python 2.7.10
BoldriniCoder:~ boldrinicoder$ /usr/local/bin/python3 --version
Python 3.6.5
BoldriniCoder:~ boldrinicoder$ python
Python 2.7.10 (default, Feb 22 2019, 21:55:15) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
BoldriniCoder:~ boldrinicoder$ python3
Python 3.6.5 (default, Jun 17 2018, 12:13:06) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

I really appreciate any kind of help. Thank you very much.

Giacomo

The easiest thing to do is to just install ROOT from Homebrew: brew install root. That should give you a recent enough version of ROOT. See https://formulae.brew.sh/formula/root for more information. Cheers,

…with the consequence that anything you build against ROOT will need to be rebuilt (and will depend on Homebrew compilers etc). If that’s not a problem, using Homebrew sounds like a good option, as Guilherme suggested!

Thank you everyone.
Yeah I know the brew way, but for now I installed the precompiled version which linked automatically with the python 2.7 and at least I’m able to work. But I never had problems before with root linking to python, what could have possibly go wrong? What if I delete all pythons (except for the OS default) and start again, would that solve the problem?

The problem is that you are mixing a python from your system with libraries from Homebrew, as shown above. It probably means that you only have libraries and headers for the Homebrew python, but are forcing ROOT to use the interpreter from the system, which is creating a broken configuration. If you specify only -DPYTHON_EXECUTABLE=... in your command line, it will work if you have the libraries installed.

1 Like