% port -v installed root
The following ports are currently installed:
root @5.34.09_1+graphviz+gsl+minuit2+opengl+python27+roofit+soversion+ssl+tmva+xml (active) platform='darwin 12' archs='x86_64'
OK, python27 is there. But my python told
% python -c "import ROOT"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ROOT
Well, PyROOT needs two files, ROOT.py and libPyROOT.so which must be visible from python. Where are they?
% port contents root | grep ROOT.py
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ROOT.py
% port contents root | grep libPyROOT.so
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/libPyROOT.so
/opt/local/lib/root/libPyROOT.so
% python -c "import ROOT"
Abort trap: 6
%/opt/local/bin/python2.7 -c "import ROOT"
Passed! What is the difference between 'em?
%/usr/bin/python
Python 2.7.5 (default, Aug 1 2013, 01:01:17)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
%/opt/local/bin/python2.7
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Well, well, well. I can set my default python as the later one by, for instance,
sudo ln -s /opt/local/bin/python2.7 /opt/local/bin/python
and exporting PATH with /opt/local/bin placed earlier than /usr/bin so that I can just write, e.g.
%python -c "from ROOT import TCanvas"
%python -c "from ROOT import TCanvas"