Skip to content

Instantly share code, notes, and snippets.

@MohamedElashri
Last active July 20, 2023 11:08
Show Gist options
  • Save MohamedElashri/1b0367992988f053a02dbfd5797fb59e to your computer and use it in GitHub Desktop.
Save MohamedElashri/1b0367992988f053a02dbfd5797fb59e to your computer and use it in GitHub Desktop.
Run ROOT on google colab, working with python 3.10 [latest python version on Colab].
!wget https://github.com/MohamedElashri/ROOT/releases/download/ubuntu/root_v6.28.04_Ubuntu_20.04.zip
!unzip /content/root_v6.28.04_Ubuntu_20.04.zip
!apt-get install git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev tar gfortran subversion
!apt-get inatall libpython3.6-dev
# The following is needed because colab upgraded the openssl library
!wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
!sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
import sys
sys.path.append("/content/root_build/")
sys.path.append("/content/root_build/bin/")
sys.path.append("/content/root_build/include/")
sys.path.append("/content/root_build/lib/")
import ctypes
ctypes.cdll.LoadLibrary('/content/root_build/lib//libCore.so')
ctypes.cdll.LoadLibrary('/content/root_build/lib//libThread.so')
ctypes.cdll.LoadLibrary('/content/root_build/lib//libTreePlayer.so')
import ROOT
h = ROOT.TH1F("gauss","Example histogram",100,-4,4)
h.FillRandom("gaus")
c = ROOT.TCanvas("myCanvasName","The Canvas Title",800,600)
h.Draw()
c.Draw()
@MohamedElashri
Copy link
Author

MohamedElashri commented Jul 5, 2023

Update: I built a ROOT version with python3.10 and updated the gist. You can use the method now without python3.6 virtual env trick. Example is provided here

I forgot to add that I updated the ROOT version to v6.28 instead of the old v6.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment