# Google Colab ROOT import

**URL:** <https://root-forum.cern.ch/t/google-colab-root-import/54220>\
**Category:** ROOT\
**Tags:** python, python3, root, jupyter\
**Created:** [March 26, 2023, 2:21am UTC](https://root-forum.cern.ch/t/google-colab-root-import/54220 "2023-03-26T02:21:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![drawal](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/6bbea6/32.png) [@drawal](https://root-forum.cern.ch/u/drawal)\
**Post date:** [March 26, 2023, 2:21am UTC](https://root-forum.cern.ch/t/google-colab-root-import/54220/1 "2023-03-26T02:21:06Z")

</div>

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:

```auto
!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

* * *

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 29, 2023, 10:52am UTC](https://root-forum.cern.ch/t/google-colab-root-import/54220/2 "2023-03-29T10:52:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 29, 2023, 1:44pm UTC](https://root-forum.cern.ch/t/google-colab-root-import/54220/3 "2023-03-29T13:44:38Z")

</div>

As shown in this old post on stackoverflow (see answer 2 in [Installing CERN ROOT on google Jupyter Notebook - Stack Overflow](https://stackoverflow.com/questions/55544013/installing-cern-root-on-google-jupyter-notebook) )

You should do this to set the correct PATH

```auto
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

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 12, 2023, 1:45pm UTC](https://root-forum.cern.ch/t/google-colab-root-import/54220/4 "2023-04-12T13:45:34Z")

</div>

Closed on April 12, 2023, 1:45pm UTC

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