【问题标题】:Installing CERN ROOT on google Jupyter Notebook在 google Jupyter Notebook 上安装 CERN ROOT
【发布时间】:2019-08-27 20:47:54
【问题描述】:

我尝试在谷歌合作的 Jupiter notebook https://colab.research.google.com 上安装 CERN ROOT http://root.cern.ch。我无法使用 ROOT 运行 python,它在以下位置崩溃: 导入ROOT

我一直像往常一样安装ROOT:

!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

脚本 APPS/root/bin/thisroot.sh 应该定义 PYTHONPATH 和 ROOTSYS 变量,所以这应该允许从 python 使用 ROOT。

问题: 运行此脚本后,环境变量未设置,因此我无法使用我的 python 运行 ROOT。

那么,如何设置这些变量????

谢谢, 马辛

【问题讨论】:

  • 您可以使用 sys.path.append('/content/root') 更新您的 PYTHONPATH。但是,更大的问题可能是您没有构建实际的部门。我建议您更详细地阅读build quickstart docs

标签: google-colaboratory root-framework


【解决方案1】:

我也试过在google colaboratory Jupiter notebook上使用ROOT,发现有些库需要在导入ROOT之前加载。以下代码至少在我的笔记本中有效。

!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()

如果您使用 ROOT v6.16.00,您会看到如下错误。

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

顺便说一下,下面列出了google colaboratory的Ubuntu、gcc、python的版本。

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)

【讨论】:

  • 如果有帮助,Colab 上的默认版本现在是 Python 3,但 pyroot 仍使用 python2.7 编译,因此快速修复只需更改 Colab 上的版本
猜你喜欢
  • 2018-05-25
  • 2018-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多