Use pyROOT + ROOT in Python Virtual Env on LXPLUS

Dear all,

I need to be able to use the XGBoost Python library on LXLPUS in conjunction with pyROOT. To do this I made a virtual environment and did ‘pip install xgboost dumpy SciPy pandas’ etc. These modules work fine. However I cannot “import ROOT” I get the error

ModuleNotFoundError: No module named 'ROOT'

However, when just typing “root” into the LXPLUS terminal ROOT starts fine. Upon entering “which root” I get “/usr/bin/root”. So ROOT is installed and recognised but import ROOT is not when using Python.

ROOT Version: 6.24/08

Thank you for replying.

I checked my root-config and the Python 3 versions match (v3.6.8). Where it the standard location of the ROOT install on LXPLUS? I have not sourced thisroot.sh I expect this is the issue but I don’t know where thisroot.sh is located.

Self answer (for lxplus):

  1. Activate your virtual environment, install any required Python packages.
  2. Once activated source the appropriate thisroot.sh. Located at
/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/<version>/<platform>

on LXPLUS. You can check the version required by running “root --version”.
You will need to source the thisroot.sh every time you re-enter the virtual env.

rpm -qf /usr/bin/root
rpm -ql python2-root
rpm -ql python36-root

Just adding some possibly useful info related to this error:

I had the same issue when trying to run a python script which included the line: “import ROOT”

I have two lxplus accounts, a primary and a secondary.
When logging in on lxplus9, both accounts have identical ROOT and Python3 versions:
ROOT Version: 6.30/04
Python 3.9.18

I noticed that the python script worked fine on the primary account but gives the “no module” error on the second account.

In the second account I ran:

source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/bin/thisroot.sh

and now the secondary account is able to import ROOT in python scripts!