Problem building root after python update


ROOT Version: 6.10/08
Platform: MACOS
Compiler: Not Provided


Dear experts,

After some changes between python 3 and python 2.7 I got some errors in
my pyROOT script

import ROOT

File "/Users/lisapaspalaki/Downloads/build_root_6_2/lib/ROOT.py", line 24, in <module>

import cppyy

File "/Users/lisapaspalaki/Downloads/build_root_6_2/lib/cppyy.py", line 61, in <module>

import libPyROOT as _backend

ImportError: dlopen(/Users/lisapaspalaki/Downloads/build_root_6_2/lib/libPyROOT.so, 2): Library not loaded: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/Python

Referenced from: /Users/lisapaspalaki/Downloads/build_root_6_2/lib/libPyROOT.so

Reason: image not found

I thought that building root again would fix the problem but the build fails.

I did:

cmake -Droofit=ON -Dminuit2=ON -DPYTHON_EXECUTABLE=/usr/bin/python -DPYHTON_INCDIR=/usr/local/include/ -DPYTHON_LIBDIR=/usr/lib .

cmake --build . -- -j4

The error I get is:

In file included from /Users/lisapaspalaki/Downloads/download_root_6_10_08/root/bindings/pyroot/src/Executors.cxx:5:

/Users/lisapaspalaki/Downloads/download_root_6_10_08/root/bindings/pyroot/src/PyROOT.h:38:10: fatal error: 'Python.h' file not

found

#include "Python.h"

^~~~~~~~~~

In file included from /Users/lisapaspalaki/Downloads/download_root_6_10_08/root/bindings/pyroot/src/MethodProxy.cxx:5:

/Users/lisapaspalaki/Downloads/download_root_6_10_08/root/bindings/pyroot/src/PyROOT.h:38:10: fatal error: 'Python.h' file not

found

#include "Python.h"

^~~~~~~~~~

1 error generated.

The python version I have is
python

Python 2.7.10 (default, Jul 15 2017, 17:16:57)

[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

and which python

/usr/bin/python

Please let me know if you have a solution to this problem.

Best,
Lisa

Which changes have you made to your setup?

Above, you are trying to use headers and libraries for different versions of Python together. That cannot work. You need to use all from /usr or all from /usr/local and make sure the version of Python for your headers and libraries is the same (i.e. make sure you don’t use Python 2.x headers and Python 3.x libraries). To make sure things are consistent, you should specify only -DPYTHON_EXECUTABLE=... on the command line to CMake. I also recommend using the latest release of ROOT on your Mac if you can. There are readily available binaries you can download from the website as well instead of building from source: https://root.cern/content/release-61600.

Thank you very much from your answer.
I builded root-6.16 from source and it seems to work now.

Best,

Lisa

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