ROOT framework snap install missing sklearn

Hi,
I recently installed the ROOT framework using the awesome snap package developed by James Carroll here https://snapcraft.io/install/root-framework/ubuntu
I am working on a HEP+ML analysis and want to use the root --notebook. There are mostly all the ML libraries I need, except sklearn. I keep trying to get my root --notebook to work with importing sklearn by giving it the path to where it is installed in my computer, but haven’t had any luck.
Do others have suggestions on how to get sklearn to work in the root --notebook environment? Or maybe a way to request sklearn to be included in the ROOT framework snap container?
Thanks!
Cheers,
Christina

Generally speaking for random extra python modules, I’d probably suggest running in pyroot (or a notebook):

import sys
import os
os.system("pip3 install scikit-learn -t pyroot_extras")
sys.path.append("pyroot_extras")

This’ll just install the modules to your $HOME directory and instruct ROOT to try load them from there.

There’s a few problems to this, you’d either have to append to the path every single time you boot up ROOT, which probably isn’t a problem in a Notebook environment (and consider using .pyrootlogin.py / .rootlogin.c), but also the extras might simply just not work. They’d also not be updated automatically with the rest of the snap.

However in this case, the scikit-learn package looks like an ideal fit for the snap and so I’ll see if I can put it in there by default, I’ll respond back later.

Thanks for the quick reply! Your suggestion above worked perfectly in my notebook. Thanks!

Things are working great now, and I’ll be on the lookout for the updated snap container :slight_smile:

For reference, here is an example of the analysis I intend to model after. It uses sklearn in omnifold.py https://github.com/hep-lbdl/OmniFold

cheers!

Hi again,

I’ve been looking into this today. I’ll try and upload a new version tomorrow, the instructions above will result in only being able to use one CPU core, and using all the cores with scikit-learn will take snap specific changes to get working. Unfortunately ROOT takes a long time to compile.

For more specific help with ROOT rather than the Snap side of things though, I’d encourage you to visit the forums https://root-forum.cern.ch/.

(For the snap people, it turns out I just need to make of snapcraft-preload due to hardcoded /dev/shm, and I’d spent hours trying to avoid having to use snapcraft-preload, but in the end it’s looking unavoidable).

There’s a new release of the snap on the store with scikit-learn bundled now, you can update to it with sudo snap refresh.

1 Like