-
-
Save MohamedElashri/dab00a84ba6a65f99fb2694504ecc39e to your computer and use it in GitHub Desktop.
# This code is for installing ROOT on Google Colab to be able to install root_numpy and root_pandas package later | |
# for version of this code which work with python3 visit | |
#https://gist.github.com/MohamedElashri/1b0367992988f053a02dbfd5797fb59e | |
!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/libMultiProc.so') | |
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/libGraf3d.so') | |
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libTreePlayer.so') | |
ctypes.cdll.LoadLibrary('/content/APPS/root/lib/libMultiProc.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() |
dear mohamed,
thank you for your job, very useful... although I hope that soon or later someone succeed to make a clean installation
did you been able to open TWeb file?
Error in TWebFile::TWebFile: https://s.../histograms_Run03965.root? does not exist
I think some path is still missing
Hi Giovanni
This method shouldn't work anymore because it doesn't work with Python 3 and colab stopped python 2 support.
You can try the new one I explained in another gist here.
https://gist.github.com/MohamedElashri/1b0367992988f053a02dbfd5797fb59e
If you are referring to this new version and have a problem with TWeb files I didn't use it before. However, I have some idea how to use it . TWebFile is using http
protocoal which is implemented in libNet. I think you need to add this line with other lib paths.
ctypes.cdll.LoadLibrary('/content/root_build/lib//libNet.so')
Let me know if this works.
Hint: you might need to build libNet
manually and mount it to the path. You can see the build instructions in the main project README.md
https://github.com/libnet/libnet
Hi
dear mohamed,
thank you for your job, very useful... although I hope that soon or later someone succeed to make a clean installation
did you been able to open TWeb file?
Error in TWebFile::TWebFile: https://s.../histograms_Run03965.root? does not exist
I think some path is still missingHi Giovanni
This method shouldn't work anymore because it doesn't work with Python 3 and colab stopped python 2 support.
You can try the new one I explained in another gist here.
https://gist.github.com/MohamedElashri/1b0367992988f053a02dbfd5797fb59eIf you are referring to this new version and have a problem with TWeb files I didn't use it before. However, I have some idea how to use it . TWebFile is using
http
protocoal which is implemented in libNet. I think you need to add this line with other lib paths.
ctypes.cdll.LoadLibrary('/content/root_build/lib//libNet.so')
Let me know if this works.
Hint: you might need to build
libNet
manually and mount it to the path. You can see the build instructions in the main project README.md
https://github.com/libnet/libnet
Thanks, yes I'm using your compiled distribution of root but acutely I loaded "brutally" all the lib with the following code
libfile = !ls /content/root_build/lib/.so
for i, lib in enumerate(libfile):
if not (lib=='/content/root_build/lib/libtbbmalloc_proxy.so' or lib=='/content/root_build/lib/libtbbmalloc.so' or lib=='/content/root_build/lib/libtbb.so'):
ctypes.cdll.LoadLibrary(lib)
without success.... looks to be a problem of "plugin" but I'm not so expert of root to understand the error
ps in colab py2 script it works perfectly and the file are accessible without any password.
Hi
dear mohamed,
thank you for your job, very useful... although I hope that soon or later someone succeed to make a clean installation
did you been able to open TWeb file?
Error in TWebFile::TWebFile: https://s.../histograms_Run03965.root? does not exist
I think some path is still missingHi Giovanni
This method shouldn't work anymore because it doesn't work with Python 3 and colab stopped python 2 support.
You can try the new one I explained in another gist here.
https://gist.github.com/MohamedElashri/1b0367992988f053a02dbfd5797fb59e
If you are referring to this new version and have a problem with TWeb files I didn't use it before. However, I have some idea how to use it . TWebFile is usinghttp
protocoal which is implemented in libNet. I think you need to add this line with other lib paths.
ctypes.cdll.LoadLibrary('/content/root_build/lib//libNet.so')
Let me know if this works.
Hint: you might need to buildlibNet
manually and mount it to the path. You can see the build instructions in the main project README.md
https://github.com/libnet/libnetThanks, yes I'm using your compiled distribution of root but acutely I loaded "brutally" all the lib with the following code
libfile = !ls /content/root_build/lib/.so
for i, lib in enumerate(libfile):
if not (lib=='/content/root_build/lib/libtbbmalloc_proxy.so' or lib=='/content/root_build/lib/libtbbmalloc.so' or lib=='/content/root_build/lib/libtbb.so'):
ctypes.cdll.LoadLibrary(lib)
without success.... looks to be a problem of "plugin" but I'm not so expert of root to understand the error
ps in colab py2 script it works perfectly and the file are accessible without any password.
Can you give me example of the code (particularly example file) that you are trying to run so that I can do some debugging?
Hi
dear mohamed,
thank you for your job, very useful... although I hope that soon or later someone succeed to make a clean installation
did you been able to open TWeb file?
Error in TWebFile::TWebFile: https://s.../histograms_Run03965.root? does not exist
I think some path is still missingHi Giovanni
This method shouldn't work anymore because it doesn't work with Python 3 and colab stopped python 2 support.
You can try the new one I explained in another gist here.
https://gist.github.com/MohamedElashri/1b0367992988f053a02dbfd5797fb59e
If you are referring to this new version and have a problem with TWeb files I didn't use it before. However, I have some idea how to use it . TWebFile is usinghttp
protocoal which is implemented in libNet. I think you need to add this line with other lib paths.
ctypes.cdll.LoadLibrary('/content/root_build/lib//libNet.so')
Let me know if this works.
Hint: you might need to buildlibNet
manually and mount it to the path. You can see the build instructions in the main project README.md
https://github.com/libnet/libnetThanks, yes I'm using your compiled distribution of root but acutely I loaded "brutally" all the lib with the following code
libfile = !ls /content/root_build/lib/.so
for i, lib in enumerate(libfile):
if not (lib=='/content/root_build/lib/libtbbmalloc_proxy.so' or lib=='/content/root_build/lib/libtbbmalloc.so' or lib=='/content/root_build/lib/libtbb.so'):
ctypes.cdll.LoadLibrary(lib)
without success.... looks to be a problem of "plugin" but I'm not so expert of root to understand the error
ps in colab py2 script it works perfectly and the file are accessible without any password.Can you give me example of the code (particularly example file) that you are trying to run so that I can do some debugging?
this is an the example working on colab with py2.
https://github.com/gmazzitelli/studenti/blob/master/read_image_root_py2.ipynb
actually reading the root file https://s3.cloud.infn.it/v1/AUTH_2ebf769785574195bde2ff418deac08a/cygnus/Data/LAB/histograms_Run04020.root
Hi Mohamed,
Thank you so much for this! It worked great for me.
dear mohamed,
thank you for your job, very useful... although I hope that soon or later someone succeed to make a clean installation
did you been able to open TWeb file?
Error in TWebFile::TWebFile: https://s.../histograms_Run03965.root? does not exist
I think some path is still missing