Import PyRoot problem

I’ve compiled ROOT using:

cmake ../root -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_INSTALL_INCLUDEDIR=/usr/include -Dgnuinstall=ON -Dall=ON -Dsoversion=ON

because i want to include ROOT library normally as common library C++.
As you can see i’ve installed ROOT in /usr/local, and after that i did “make -j2”, “make install” and than “source /usr/local/bin/thisroot.sh”.
If i write “root” in my terminal it works very well, but if i open python and then i write “import ROOT” this is what appen:

casa@casa-server:~$ python3
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ROOT'

It is the same with python2:

casa@casa-server:~$ python2
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ROOT

What is the problem?

I tried to do:

source $ROOTSYS/bin/thisroot.sh

and now i can use ROOT library inside only Python2.7 (maybe because Python3 has Anaconda).

casa@casa-server:~$ python2.7
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ROOT
>>> quit()
casa@casa-server:~$ source $ROOTSYS/bin/thisroot.sh
casa@casa-server:~$ python2.7
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> quit()
casa@casa-server:~$

The problem now is that i have to repeat the command when i restart the terminal.
Some advices?

Add source /usr/local/bin/thisroot.sh to your ~/.bash_profile?

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