WSL: pyROOT from VS Code only works calling thisroot.sh manually

_ROOT Version:6.26/10
_Platform: Windows 10 with WSL2- Ubuntu-22.04.1
_Compiler:g++

When I try to call import ROOT from python3 in VS Code terminal it says that ROOT module does not exist until I manually run thisroot.sh
This is very strange, in fact I checked a lot of things like:

  • python version is the same of ROOT
  • root-config command works
  • if I call root in the terminal it opens root (I’ve added the source command into bashrc)

It seems all ok but it dows not work… any suggestion?

yes that’s weird. May be @vpadulan has an idea.

Hi @Grufoony ,

how did you install ROOT?

Cheers,
Enrico

Hi, I’ve downloaded the binary dist for ubuntu 22

The problem could be that, in the VSCode terminal, ROOT is not sourced correctly. You can open that terminal and check that these two environment variables are set correctly (they are set by source thisroot.sh):

~ echo $ROOTSYS
/home/blue/ROOT/master/cmake-build-foo
~ echo $PYTHONPATH
/home/blue/ROOT/master/cmake-build-foo/lib

In particular as you see PYTHONPATH tells Python to look in $ROOTSYS/lib for the ROOT Python module.

Cheers,
Enrico

Ok I checked and, despite both $PYTHONPATH and $ROOTSYS were set correctly it didn’t work.
I’ve searched through other programs and found that one of them changed the $RPYTHONPATH (don’t know why the command echo kept to schow me the root’s one).
Removing this program I have solved the problem.

Ty for the help c:

1 Like

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