Hi, I have the exact same problem as described in this post, except I use Scientific Linux 7 and I compiled ROOT 6.28.6 from source for our computer with G++ (GCC) 11.2.0 and
I have no system-wide installations, but I have older versions on the computer, yes. We change the versions by sourcing the appropriate thisroot.sh
According to the error python picks up the proper version in the notebook too
I checked in the notebook with:
%%bash
echo $PATH
and the correct one appears to be the only root directory in the $PATH.
Calling the test above in a simple python terminal also works:
$ python3
Python 3.6.8 (default, Nov 9 2023, 05:22:21)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.Experimental.RCanvas.GetCanvases()
vector<shared_ptr<ROOT::Experimental::RCanvas> >{}
>>>
Currently we support all versions of Python 3, so that should not be the direct cause for the problem seen by the user. The next thing I would try is to make sure that the Python executable used in the ROOT installation is the same Python executable that launches the jupyter notebook.
3.6.8 (default, Nov 9 2023, 05:22:21)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
/usr/bin/python3
importing ROOT still meets the same show-stopper error.
In my terminal calling this python:
$ /usr/bin/python3
Python 3.6.8 (default, Nov 9 2023, 05:22:21)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> lOfC = ROOT.Experimental.RCanvas.GetCanvases()
>>> print(lOfC)
{}
>>>
The module now imports and I can read root files and operate on histograms, which was the most important part of the whole thing for me.
However, when I try to do a plot with ROOT the script that works in the interactive python shell gives an error. Maybe this hints at something? The simple script:
h = ROOT.TH1F("gauss","Example histogram",100,-4,4)
h.FillRandom("gaus")
c = ROOT.TCanvas("myCanvasName","The Canvas Title",800,600)
h.Draw()
c.Draw()
The error I am getting in the notebook is:
IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]!
You are probably missing the definition of cling::runtime::gCling
Maybe you need to load the corresponding shared library?
Error in <TH1F::FillRandom>: Unknown function: gaus
IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]!
You are probably missing the definition of cling::runtime::gCling
Maybe you need to load the corresponding shared library?
I dont think anything goes into the system directories. I have -DCMAKE_INSTALL_PREFIX="/cern_root_6.28.6_cpp17" so install should just copy the build results here, right?
Welcome to JupyROOT 6.28/06
Error in callback <bound method CaptureDrawnPrimitives._post_execute of <JupyROOT.helpers.utils.CaptureDrawnPrimitives object at 0x7ff0922f0358>> (for post_execute):
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/install_new_root/build_dir/lib/JupyROOT/helpers/utils.py in _post_execute(self)
456
457 def _post_execute(self):
--> 458 NotebookDraw()
459
460 def register(self):
~/install_new_root/build_dir/lib/JupyROOT/helpers/utils.py in NotebookDraw()
446 DrawGeometry()
447 DrawCanvases()
--> 448 DrawRCanvases()
449
450 class CaptureDrawnPrimitives(object):
~/install_new_root/build_dir/lib/JupyROOT/helpers/utils.py in DrawRCanvases()
439
440 def DrawRCanvases():
--> 441 rdrawers = GetRCanvasDrawers()
442 for drawer in rdrawers:
443 drawer.Draw()
~/install_new_root/build_dir/lib/JupyROOT/helpers/utils.py in GetRCanvasDrawers()
411 def GetRCanvasDrawers():
412 if not RCanvasAvailable(): return []
--> 413 lOfC = ROOT.Experimental.RCanvas.GetCanvases()
414 return [NotebookDrawer(can.__smartptr__().get()) for can in lOfC if can.IsShown()]
415
ValueError: static const vector<shared_ptr<ROOT::Experimental::RCanvas> > ROOT::Experimental::RCanvas::GetCanvases() =>
ValueError: nullptr result where temporary expected
While in my terminal:
$ which root
~/install_new_root/build_dir/bin/root
$ echo $PATH
/home/pmajor/install_new_root/build_dir/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/pmajor/.local/bin:/home/pmajor/bin
$ echo $PYTHONPATH
/home/pmajor/install_new_root/build_dir/lib
$ python3
Python 3.6.8 (default, Nov 9 2023, 05:22:21)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.Experimental.RCanvas.GetCanvases()
vector<shared_ptr<ROOT::Experimental::RCanvas> >{}
Ok, I compiled python 3.10 for our machine, which was not exactly a walk in the park and built root against that. Now it seems to work. I ll keep testing and will let you know if sg is not right.