ROOTBook and Python kernel on Mac OSX

Dear all,

I am on Mac OSX and I have a happily functioning ROOT/pyROOT installation from homebrew. I now want to try the ROOTBooks, and I have installed the dependencies as suggested here.

Everything starts up fine with root --notebook, but simply creating a new python notebook and trying to import ROOT shows that the module is not visible:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-ee8dc4376aa8> in <module>()
----> 1 import ROOT

ImportError: No module named ROOT

while “import ROOT” works correctly in a terminal in the same notebook session.

Any hints? System information are below.

Thanks,
Caterina

python --version: Python 2.7.10
ROOT Version (e.g. 6.12/02): 6.10/08
Platform, compiler (e.g. CentOS 7.3, gcc6.2): host-78-76-230-23:JupyterDijets urania277$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


Hi @caterina,

If you write:

!echo $PYTHONPATH

in one of the notebook cells, what does it print? Does you PYTHONPATH contain the lib folder in ROOT?

The second thing I would check is your PYTHONPATH right before calling root --notebook, does it contain the aforementioned folder?

One last thing I would like to mention is that you can create your ROOTbooks and easily share them with your colleagues without any local installation just by connecting to the SWAN service:

https://swan.cern.ch

You just need to have a CERNBox created (https://cernbox.cern.ch) before you first log in to SWAN.

Cheers,
Enric

Hi @etejedor,
thanks for the reply!
Here’s my $PYTHONPATH outside the notebook

jocke:JupyterDijets urania277$ echo $PYTHONPATH 
/usr/local/Cellar/root/6.10.08/lib/root

Indeed, the path is not in the notebook’s $PYTHONPATH.

[1] !echo $PYTHONPATH
/usr/local/Cellar/ipython@5/5.7.0/libexec/lib/python2.7/site-packages:/usr/local/Cellar/ipython@5/5.7.0/libexec/vendor/lib/python2.7/site-packages

Curiously enough though, it’s outside the notebook - this is in a terminal in the Jupyter browser.

bash-3.2$ echo $PYTHONPATH
/usr/local/Cellar/root/6.10.08/lib/root:/usr/local/Cellar/root/6.10.08/lib/root:/usr/local/Cellar/jupyter/1.0.0_3/libexec/lib/pytho
n2.7/site-packages:/usr/local/Cellar/jupyter/1.0.0_3/libexec/vendor/lib/python2.7/site-packages

I am rather puzzled…how did I get the environments to disagree?

Thanks,
Caterina

Hi @caterina,

If you spawn the Jupyter server from a terminal process, it should inherit the PYTHONPATH from that process.

Just to make sure ROOT is not interfering, can you spawn your Jupyter server with jupyter notebook instead of root --notebook? Do you observe the different PYTHONPATHs also in this case?

Cheers,

Enric

Hi @etejedor,

thanks, that did it! I am not sure why this would work while the root --notebook wouldn’t.

I’ve also taken a look at SWAN - nice idea for those with a CERN account, so it’s great for development.

I’m also trying to get this to work using the Jupyter Docker stacks as it would be very convenient for teaching. The discussion is here: https://github.com/jupyter/docker-stacks/issues/640. I’m not sure you want to close this one as I still see unexpected path in the ROOTBooks, but I don’t need them anymore :slight_smile:

Caterina

Hi @caterina,

Thanks for reporting back, I will try to reproduce on MacOS (cannot on Linux).

Looking at the PYTHONPATH you get in the notebook, I suspect it is IPython messing around with it:

I need to see why root --notebook triggers this - in the end we just do jupyter notebook as you did.

Regarding the Docker stacks, you are planning to prepare a Docker image with ROOT and Jupyter so that students can work with notebook during a course?

Cheers,
Enric

Hi @etejedor,

it may also have to do with the way mac/brew deal with their own environments. I had similar problems before. So if it’s only my case, don’t spend too much time on it :slight_smile:

Regarding the Docker stacks, you are planning to prepare a Docker image with ROOT and Jupyter so that students can work with notebook during a course?

That’s the idea, in the first (ROOT-less) iteration of a graduate-level Jupyter course we used conda, but it already didn’t work too smoothly as some people had trouble depending on OS/setup/etc. Now that we’re adding a particle physics chunk we would really like to use ROOT, so I’m testing the waters in advance. Having a Docker image seems like the simplest solution, as students need to be able to work offline on their projects as well.

Thanks,
Caterina

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