I’ve installed root from source on the physic machine, with python mounted from a cvmfs and root installed from source in my local directory. Root can be booted from the command line in C++ form, but when I try to perform even the first line of the primer in PyROOT, the following happns:
import ROOT
h = ROOT.TH1F("myHist", "myTitle", 64, -4, 4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'ROOT' has no attribute 'TH1F'
Hi! I think there could be something wrong with your setup, I just checked and it works for me building ROOT master. Which flags did you use while building ROOT? Can you attach here please output of CMake configuration step?
-- Detected ROOT_VERSION 6.23.01
-- Looking for Python
-- Found GCC. Major version 9, minor version 2
-- ROOT Platform: linux
-- ROOT Compiler: GNU 9.2.0
-- ROOT Processor: x86_64
-- ROOT Architecture: linuxx8664gcc
-- Build Type: 'Release' (flags = '-O3')
-- Compiler Flags: -std=c++14 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O3
-- ROOT default compression algorithm: zlib
-- PyROOT will be built for version 3.7.5
-- Looking for ZLib
-- Looking for Freetype
-- Looking for PCRE
-- Looking for LZMA
-- Looking for X11
-- Could NOT find GIF (missing: GIF_LIBRARY GIF_INCLUDE_DIR)
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
-- Building AfterImage library included in ROOT itself
-- Looking for GSL
-- Looking for LibXml2
-- Looking for MySQL
-- Looking for SQLite
-- Downloading and building XROOTD version
-- Cannot select cudnn without selecting cuda or tmva-gpu. Option is ignored
-- Looking for BLAS for optional parts of TMVA
-- Building LLVM in 'Release' mode.
-- Native target architecture is X86
-- Threads disabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Building with -fPIC
-- Constructing LLVMBuild project information
-- Linker detection: GNU ld
-- SysLibs: rt;dl;tinfo;-lpthread;/usr/lib64/libz.so
-- Targeting X86
-- Targeting NVPTX
-- Clang version: 5.0.0
-- Cling version (from VERSION file): ROOT_0.8~dev
-- Cling will look for C++ headers in '/cvmfs/icecube.opensciencegrid.org/py3-v4.1.1/RHEL_7_x86_64/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/gcc-9.2.0-3w2q6zybuxylortxl4ws4ovb2skjd342/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0:/cvmfs/icecube.opensciencegrid.org/py3-v4.1.1/RHEL_7_x86_64/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/gcc-9.2.0-3w2q6zybuxylortxl4ws4ovb2skjd342/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/x86_64-pc-linux-gnu:/cvmfs/icecube.opensciencegrid.org/py3-v4.1.1/RHEL_7_x86_64/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/gcc-9.2.0-3w2q6zybuxylortxl4ws4ovb2skjd342/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/backward' at runtime.
-- And if not found, will invoke: '/cvmfs/icecube.opensciencegrid.org/py3-v4.1.1/RHEL_7_x86_64/bin/c++ ' for them.
-- Performing Test found_stdstringview
-- Performing Test found_stdstringview - Failed
-- Performing Test found_stdexpstringview
-- Performing Test found_stdexpstringview - Success
-- Performing Test found_stod_stringview
-- Performing Test found_stod_stringview - Failed
-- Performing Test found_stdapply
-- Performing Test found_stdapply - Failed
-- Performing Test found_stdinvoke
-- Performing Test found_stdinvoke - Failed
-- Performing Test found_stdindexsequence
-- Performing Test found_stdindexsequence - Success
-- ROOT Configuration
System Linux-3.10.0-957.12.1.el7.x86_64
Processor 16 core Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz (x86_64)
Build type Release
Install path /home/rclark/rootinstall
Compiler GNU 9.2.0
Compiler flags:
C -Wno-implicit-fallthrough -pipe -Wall -W -pthread -O3 -DNDEBUG
C++ -std=c++14 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O3 -DNDEBUG
Linker flags:
Executable -rdynamic
Module
Shared -Wl,--no-undefined -Wl,--hash-style="both"
-- Enabled support for: asimage builtin_afterimage builtin_clang builtin_gl2ps builtin_llvm builtin_lz4 builtin_nlohmannjson builtin_openui5 builtin_tbb builtin_vdt builtin_xrootd builtin_xxhash builtin_zstd clad dataframe exceptions gdml http imt mathmore mlp mysql roofit webgui root7 runtime_cxxmodules shared sqlite ssl tmva tmva-cpu spectrum vdt x11 xml xrootd
-- Configuring done
EDIT: The inputs I used to congifure and build were:
Can you re-run the same command from empty build directory please (just create a new one)? I need to see a part when you try to initially find/check Python components. In my case it looks like this:
-- Detected ROOT_VERSION 6.23.01
-- Looking for Python
-- Found Python3: /usr/bin/python3.8 (found version "3.8.6") found components: Interpreter Development NumPy Development.Module Development.Embed
-- Could NOT find Python2 (missing: Python2_EXECUTABLE Python2_INCLUDE_DIRS Python2_LIBRARIES Python2_NumPy_INCLUDE_DIRS Interpreter Development NumPy Development.Module Development.Embed)
So the part where it checks python components gives this
Detected ROOT_VERSION 6.23.01
-- Looking for Python
-- Found Python3: /cvmfs/icecube.opensciencegrid.org/py3-v4.1.1/RHEL_7_x86_64/bin/python (found version "3.7.5") found components: Interpreter Development NumPy
You’d have hoped so, only now I’m getting a completely different error - it’s claiming the version of root and python are in conflict. This is despite:
yet when I try to import ROOT, the following error occurs:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Traceback (most recent call last):
File "/home/rclark/newinstall/lib/cppyy/__init__.py", line 60, in <module>
importlib.import_module(libcppyy_mod_name)
File "/cvmfs/icecube.opensciencegrid.org/py3-v4.1.1/RHEL_7_x86_64/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
File "<frozen importlib._bootstrap>", line 583, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /home/rclark/newinstall/lib/libcppyy_backend3_7.so: undefined symbol: gExceptionHandler
During handling of the above exception, another exception occurred:
File "/home/rclark/newinstall/lib/ROOT/__init__.py", line 22, in <module>
import cppyy
File "/home/rclark/newinstall/lib/cppyy/__init__.py", line 64, in <module>
libcppyy_mod_name, major, minor))
ImportError: Failed to import libcppyy3_7. Please check that ROOT has been built for Python 3.7
What’s also interesting is that. after running the source thisroot.sh within the newly installed root directory, it seems to reset to Python 2.7.5… which also displays version incompatibility with the installed root.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rclark/newinstall/lib/ROOT/__init__.py", line 22, in <module>
import cppyy
File "/home/rclark/newinstall/lib/cppyy/__init__.py", line 64, in <module>
libcppyy_mod_name, major, minor))
ImportError: Failed to import libcppyy2_7. Please check that ROOT has been built for Python 2.7
Ah, sorry, I nded up completely uninstalling and using a version loaded on the cvmfs server instead. I’m not sure I could reproduce the error, to be honest.It might have come from my terminal crashing during the build process, and then slightly jumping when I restarted the build process? That’s all I can think of.