Installing CERN ROOT on google Jupyter Notebook

淺唱寂寞╮ 提交于 2021-01-28 02:53:58

问题


I have tried to install CERN ROOT http://root.cern.ch on google colaboratory Jupiter notebook https://colab.research.google.com. I can't get python running with ROOT, it crashes at: import ROOT

I have been installing ROOT as usual:

!mkdir -p APPS
!pwd
!cd APPS && wget https://root.cern/download/root_v6.16.00.Linux-ubuntu18-x86_64-gcc7.3.tar.gz 
!cd APPS && tar -xf root_v6.16.00.Linux-ubuntu18-x86_64-gcc7.3.tar.gz

!ls APPS/root/bin/thisroot.sh
!source APPS/root/bin/thisroot.sh
!echo $ROOTSYS
!echo $PYTHONPATH

import ROOT

The script APPS/root/bin/thisroot.sh should define PYTHONPATH and ROOTSYS variables, so this should allow to use ROOT from python.

PROBLEM: After running this script the environmental variables are not set, so I can't run ROOT with my python.

So, how to setup these variables????

Thanks, Marcin


回答1:


also I have tried to use ROOT on the google colaboratory Jupiter notebook, and I found that some libraries should be loaded before importing ROOT. The following code works at least in my notebook.

!mkdir -p APPS
!pwd
!cd APPS && wget https://root.cern.ch/download/root_v6.13.08.Linux-ubuntu18-x86_64-gcc7.3.tar.gz 
!cd APPS && tar -xf root_v6.13.08.Linux-ubuntu18-x86_64-gcc7.3.tar.gz

import sys
sys.path.append("/content/APPS/root/lib")
import ctypes
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libCore.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libThread.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libImt.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libRIO.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libNet.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libTree.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libMathCore.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libMatrix.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libHist.so')
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libGraf.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()

If you use the ROOT v6.16.00, you would see an error as below.

OSError: /content/APPS/root/lib/libImt.so: undefined symbol: _ZN3tbb10interface78internal20isolate_within_arenaERNS1_13delegate_baseEl

By the way, the versions of Ubuntu, gcc, and python of the google colaboratory are listed below.

Ubuntu 18.04.2 LTS (Bionic Beaver)
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) 
python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)


来源:https://stackoverflow.com/questions/55544013/installing-cern-root-on-google-jupyter-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!