Impossible import ROOT from python

I am using a Mac 10.13.4
I have a file .ROOT which is export from Geant4.
I have installed root by cmake and python, however, I can not import ROOT from python

In [1]: import ROOT
ImportError                               Traceback (most recent call last)
<ipython-input-1-b332e25ada1f> in <module>()
----> 1 import ROOT
ImportError: No module named ROOT

Could anybody please help me?
Thank you in advance.

ROOT Version (e.g. 6.13/03): Built for macosx64
python 2.7.10

Is the directory where you have in your PYTHONPATH? If not, your Python won’t be able to find it.

Thank you very much to figure out the problem Amadio,
I am a newbie in bash_profile ( I am using Mac). Could you please help me to link them together.
I have that file here: /Users/hoang/root/build/lib/
I have installed my python in: /Users/hoang/Library/Python/2.7/lib/python/site-packages

thank you in advance.
hoang thuong

Please add

export PYTHONPATH=$PYTHONPATH:/Users/hoang/root/build/lib

to your ~/.bash_profile setup. That should do. Cheers,

Thank you again for your help amadio,

this is my .bash_profile:

export PATH=$PATH:/usr/local/bin
#alias sshcc=‘ssh -Y’

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

export PYTHONPATH=$PYTHONPATH:/Users/hoang/root/build/lib

#export PYTHONPATH="$PYTHONPATH:/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7"
#export PYTHONPATH="$PYTHONPATH:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"

AND This is python places:

print ‘\n’.join(sys.path)


This still doesn’t work (import ROOT), should I reinstall python 2.7?


The place for ROOT should probably come last in your list, otherwise ROOT may try to import modules that will not be found. Please post the errors you get too, otherwise it’s hard to guess what’s happening. Thank you.

1 Like

Thank amadio again,

It works now with the python inside a root TPython::Prompt().
In Ipython or python independently it has error when I try to import ROOT( import cppyy).
Anyway thank you very much, I can work with ROOT file now and I would like to close this topic to move to another topic.


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