so the script “thisroot.sh” should be executed everytime I open a session (and I manually checked it by adding an output string inside thisroot.sh).
I tried importing ROOT as a module for Python 2.7.15. The problem is, when I open Python and import ROOT i get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named ROOT
Then, if I manually execute thisroot.sh (by typing the same line that’s inside my .bashrc file), I manage to import ROOT without any problems and it works fine.
Why are the lines in my .bashrc not enough? Thank you!
EDIT: I forgot to say that everything else works fine without the need of manually run thisroot.sh
_ROOT Version: 6.18
_Platform: ubuntu 18.04.3 on Windows 10 WSL Compiler: Not Provided
adding that line just solved the problem. I tried again following your advice and I found out that now (I’ve just re-built ROOT) I can compile without the export, so I removed that line. I doubt it has something to do with the upgrade of ROOT; instead, I believe I made a mistake the first time I built it! Thanks!
I use python 2.7.15 installed in the WSL environment, and I start it by typing python in my WSL bash!
By comparing the env outputs, before and after manually executing thisroot.sh, I can see that lots of variables (DYLD_LIBRARY_PATH, ROOTSYS, LIBPATH, PYTHONPATH…) change from “home” to “ROOT’s directory”; if you need me to, I can paste the complete outputs!
After manually running thisroot.sh, pyROOT works perfectly!
Are you able to just run root (only sourcing thisroot.sh in .bashrc)?
If not, perhaps you have other login script/s messing with the variables? Check if you have any of these files in your home: .bash_profile, .bash_login, .profile
If so, you can try adding this line:
echo $ROOTSYS
at the end of .bashrc and of each of the others, to see if it was correctly defined by .bashrc and maybe find where it is being changed.
Now, if I try to import ROOT in python I get the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/d/root6.18/lib/ROOT.py", line 24, in <module>
import cppyy
File "/mnt/d/root6.18/lib/cppyy.py", line 61, in <module>
import libPyROOT as _backend
ImportError: libTree.so: cannot open shared object file: No such file or directory
Anyways, if I manually run thisroot I can still import ROOT without any problem.
I don’t know the WSL file structure, but it seems weird that ROOT works when your variables are pointing to “home” yet your ROOT seems to be in “/mnt/d”. If ROOT is working with that configuration I suppose it should also run in python. A few things:
1 - What is the output of:
cd; pwd; ls -a
and then:
cat .bashrc
and
cat .profile
2 - Do you really need to compile root? You can just use the precompiled version for ubuntu 18 (as long as you have a 64-bit system, and since you already compiled it you should already have all the prerequisites installed); delete all current references to root in your bashrc and profile files, unzip the download to a folder and add only the “source” line at the end of .bashrc); this should be all that you need in normal situations.
Alright, thanks to your advice I think I’ve spotted the problem: I’ll try to describe it because it could happen to anyone using WSL.
There is a conflict between WSL and Windows, since my ROOT dir is in a partition outside WSL’s environment. This means that, when thisroot.sh is executed by .profile, it can’t find root-config and it leads to this error:
root-config: command not found
When I first built ROOT I found a workaround by adding ROOT’s dir in Windows’ environmental variable (path): this variable is added in WSL $PATH and thisroot.sh could finally find root-config.
That’s why I could run ROOT even if WSL variables were pointing “home”; but I couldn’t use pyROOT because those variables wern’t set correctly.
I solved the problem by removing ROOT from Windows’ path and setting WSL’s environmental variables manually, by creating a script (sourced by .profile) containig the following lines: