Google Colab ROOT import

Hi all,

I’m trying to set up ROOT in a Google Colab environment, by installing a pre-compiled binary distribution.

First, I’m finding the system information by running !lsb_release -a, which returns the following:

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal

Then, I install and unpack the appropriate pre-compiled distribution:

!wget https://root.cern/download/root_v6.28.02.Linux-ubuntu20-x86_64-gcc9.4.tar.gz
!tar -xzvf /content/root_v6.28.02.Linux-ubuntu20-x86_64-gcc9.4.tar.gz
!source /content/root/bin/thisroot.sh

But when I run a cell with import ROOT, I get a module not found error. I’m not sure why this is happening as I thought I could just set up ROOT as I would on an Ubuntu system. Any help or advice would be appreciated!

ROOT Version: 6.28.02
Platform: Google Colab
Compiler: Not Provided


Hi,
I think the correct environment is not passed to the cell, after calling !source /content/root/bin/thisroot.sh.
There should be a different way to set the correct environment variables to importing ROOT in the collar notebook cell.

Lorenzo

As shown in this old post on stackoverflow (see answer 2 in Installing CERN ROOT on google Jupyter Notebook - Stack Overflow )

You should do this to set the correct PATH

import sys
sys.path.append("/content/root/lib")

However, it will still not work, because ROOT has been built with Python 3.8 and Colab uses Python 3.9. I don’t know if you can use Python3.9 in Colab. Otherwise the only solution would be to download the ROOT sources and compile it

Lorenzo

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