PYROOT jupyter

Hi,

I am trying to use PYROOT with jupyter.
Using Anaconda 2.7 python (as my ROOT installation apparently was not built with p3 and I would get the ImportError: dynamic module does not define module export function (PyInit_libPyROOT)
error).

Initially import ROOT would produce no module found, then I added
. /usr/local/Cellar/root6/6.06.08/libexec/thisroot.sh to bash_profile, and now the kernel dies.

Can anyone help?

Edit: console message

Fatal Python error: PyThreadState_Get: no current thread
[I 12:35:01.315 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 69d4c78f-69d3-4389-ab25-9ac863cc45d9 restarted

Answer: conflicting python versions on the system. Removed anaconda and a bit of tinkering and it worked.

1 Like

I would like to use jupyter (and PyRoot), however I am very begginer in this bussiness. And your answer is not much satisfying.

1/ I followed web and I have found that anaconda is highly recommended method for jupyter, I did it, I have localy python and jupyter and it is great

2/ I have installed 6.08.06 / removed PATH with local anaconda / and I can run example from https://root.cern.ch/pyroot and some of the things from tutorial/pyroot

3/ Without anaconda in PATH, I dont have jupyter, with anaconda in PATH I cannot run demo.py

What is the real solution? Where to find a correct steps for install?
Thank you
Jaromir

Hi,

I think the best method to install Jupyter or any python package really depends on your taste and configuration. What I can say regarding ROOT and Jupyter is that both python2 and 3 are supported starting from release 6.09/02 - just note that the binaries which we distribute are based on Python2.

Cheers,
D

Thank you.

I am somehow on a wrong track, I must miss some basic context, something with libstdc++.so and I need a hint…

  • Is there possible to have anaconda3 from continuum.io installed and root 6 on top of that?

  • How do people who use Jupyter notebooks exactly install root6?
    Thanks
    J

My experiences:
1 - No anaconda: I have compiled 6.09.02 now (without anaconda in PATH), and I cannot run a notebook.

 ~ $ rootnb.exe                                            
Error starting ROOT notebook -- please check that Jupyter is installed

2 - Afterparty anaconda If I include anaconda to PATH after the compilation, I can run Jupyter. But it crashes when I start rootc++ kernel due to different libstdc++.so problem

[NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 641088db-a4d4-40fc-912f-80b7441271d8 restarted
Traceback (most recent call last):
  File "/home/ojr/anaconda3/lib/python3.5/runpy.py", line 174, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
....
ImportError: /home/ojr/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/ojr/02_GIT/root.build/lib/libPyROOT.so)

3 - Compilation with anaconda If I include anaconda in PATH and start a new compilation of 6.09.02. That fails - the libstdc++.so again.

[ 67%] Generating G__MultiProc.cxx, ../../lib/libMultiProc_rdict.pcm, ../../lib/libMultiProc.rootmap
[ 67%] Generating G__HistFactory.cxx, ../../lib/libHistFactory_rdict.pcm, ../../lib/libHistFactory.rootmap
/home/ojr/02_GIT/root.build/bin/rootcling: /home/ojr/anaconda3/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/ojr/02_GIT/root.build/lib/libRIO.so)
.....

Hi,

I don’t know if you can anaconda3 and root6 installed on top of it. We do not test this combination in our CI platforms.
I remember I installed jupyter with pip3 (both on ubuntu and osx) and it worked out fine.

About 3, somehow the libstdc++ takes precedence with respect to the one used to build part of ROOT. There could be effects linked to an inconsistent build (part of root with one libstdc++ part with some other).

D

1 Like

Thank you.
I removed anaconda3 things and I can do basically the same with python3 that comes with ubuntu 16.04, including Jupyter. Thank you again.

But - I still have a problem. I have installed jupyter, metakernel, development version of root 6.09.02 - based on instructions https://github.com/root-project/root/tree/master/bindings/pyroot/JupyROOT . I can run jupyter notebook or rootnb.exe, but at the moment I start root c++ kernel, it makes an error.

Most probably I missed something, import ROOT and simple example in python3 works. The path inthe list is root.build, but when I do source thisroot.sh it becomes correct ~/root/with the same result. Any advice is appreciated.

Kernel started: 3d51cfe3-ef77-4d36-8600-5aa0ae74fd60
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 174, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.5/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/ojr/02_GIT/root.build/lib/JupyROOT/__init__.py", line 1, in <module>
    from JupyROOT import cppcompleter, utils
  File "/home/ojr/02_GIT/root.build/lib/JupyROOT/cppcompleter.py", line 8, in <module>
    from JupyROOT import utils
  File "/home/ojr/02_GIT/root.build/lib/JupyROOT/utils.py", line 25, in <module>
    import ROOT
  File "/home/ojr/02_GIT/root.build/lib/ROOT.py", line 24, in <module>
    import cppyy
  File "/home/ojr/02_GIT/root.build/lib/cppyy.py", line 61, in <module>
    import libPyROOT as _backend
ImportError: dynamic module does not define module export function (PyInit_libPyROOT)

Hi,

thanks for your perseverance. I think our builds are only python2 based for the moment. Would it be possible for you to build root based on python 3?

Cheers,
D

1 Like

Oh. Really, import ROOT works with python but not with python3. So this was a point.

Following this answer http://stackoverflow.com/a/37857536/2324000 I managed to have python2 and python 3 kernels. However, no influence on the previous error. Maybe I dont know how to start jupyter of python2.

Now, I think, what you mean by your question. I would like to have root built with python3, it is going to be a future soon. I have no idea what could I do, though… Could you tell me more? Thank you
Jaromir
Edit: I see now that python3 was a topic Feb 2016 … Jupyter Notebook with python3 (Python3.4) and ROOT
and there is probably a way Problem using ROOT with jupyter notebook

Hi,

in order to build with python3 enabled, just add the -Dpython3=ON option at configuration time. Before, just make sure to have both python3 and the related development files available (e.g. Python.h).

Cheers,
D

1 Like

Thank you, with version 06-09-02 I finaly managed to run the example https://root.cern.ch/notebooks/HowTos/HowTo_ROOT-Notebooks.html
It is kind of fragile - if I re-run, create second histo same name, fit crashes.

But finally, I got there. Thank you

Hi,

it is not the case for me. Can you share your notebook?

Cheers,
D

Hi all,

I’ve just started to use Python and Jupyter and I would like to create a ROOTBook in order to combine Jupyter and ROOT. Therefore, I followed the instructions that can be found on several pages (installed Python 2.7 and ROOT6), but when I try to import ROOT in my ROOTBook I get the following error message:


ImportError Traceback (most recent call last)
in ()
----> 1 import ROOT

ImportError: No module named ROOT

Sorry in advance if this question might have been answered before!
I would be grateful for any kind of help!

Best regards,
Theresa

Hi Theresa,

is the environment set up for ROOT? Can you import ROOT in regular Python? Did you source the “bin/thisroot.sh” script?

Cheers,
D

Hi,

thanks for your reply.
Yes, I did source the script. Is it possible that the environment variables are not set correctly?

Cheers,
Theresa

Hi Theresa,

I do not have enough info to answer. How did you start the notebook?

Cheers,
D

I followed the instructions on the ROOT homepage, namely:

pip install jupyter metakernel
root --notebook

After that it opens but when I choose the C++ kernel instead of Python2, the kernel dies.

Regards,
Theresa

Hi Theresa,

are you on osx? If yes what version and what version of XCode and what
version of ROOT?

What happens if you launch jupyter, not from ROOT, and type import ROOT?

Cheers,

   D

Hi,

I’ve installed Quartz version 2.7.11 and Root 6.10/07

If I launch jupyter and import ROOT I get the same error message, namely:


ImportError Traceback (most recent call last)
in ()
----> 1 import ROOT

ImportError: No module named ROOT

Cheers,
Theresa

Ok,

even simpler: can you import ROOT from:

  1. ipython
  2. python
    (no jupyter).

Cheers,
D