Python: No module named 'root'

When I try to import root on python3 I get the error:
ModuleNotFoundError: No module named 'root'

I compiled root from source by using

cmake -DCMAKE_INSTALL_PREFIX=/opt/ROOT -DPYTHON=ON -Dpyroot=ON -DPYTHON_EXECUTABLE=/usr/bin/python3.8 ..

While configuring it said found python

in my config file it says:

BUILDPYTHON    := yes
PYTHONLIBDIR   := /usr/lib/x86_64-linux-gnu
PYTHONLIB      := /usr/lib/x86_64-linux-gnu/libpython3.8.so
PYTHONINCDIR   := $(filter-out /usr/include, /usr/include/python3.8)
PYTHONLIBFLAGS :=
PYTHONEXE      :=

I sourced the ROOTSYS to my ~/.bashrc
I also added root/lib to my PYTHONPATH
When I do root-config --has-python it says no
When I do root-config --features it says:

cxx14 asimage builtin_afterimage builtin_clang builtin_gl2ps builtin_llvm builtin_lz4 builtin_lzma builtin_nlohmannjson builtin_openui5 builtin_tbb builtin_vdt builtin_xrootd builtin_xxhash builtin_zstd clad dataframe exceptions fftw3 fitsio gdml http imt mathmore mlp mysql opengl pyroot roofit webgui root7 runtime_cxxmodules shared ssl tmva tmva-cpu tmva-pymva spectrum vdt x11 xml xrootd

I’m not sure if it has anything to do with my problem but after the installation I had an error when I run root:
It was something like … file doesn’t exist in /opt/ROOT/etc/…
When I checked that directory that file was there but etc directory didn’t have permission for user and other. So I gave permission with: sudo chmod -R a+rx etc
Then root started to work.

Also in libraries I try to find libpyroot but it doesn’t exist.

Here is my make output:
make.out.txt (950.6 KB)

There is no other ROOT installation in my PC this is my first time installing ROOT to this pc.

ROOT Version:6.23/01
Platform: Xubuntu 20.04

root-config --has-pyroot # "pyroot" in ROOT 6 was "python" in ROOT 5

BTW. Regardless of the version, the python’s module is named “ROOT”, not “root”.

it is yes

I tried with both root and ROOT, both doesn’t work

You MUST use EXACTLY the same Python version (and the same compiler) that your ROOT binaries were built for (otherwise, expect mysterious crashes anywhere, anytime):

root-config --python-version # C/C++ calling python ;
root-config --python2-version # python 2 calling C/C++ ;
root-config --python3-version # python 3 calling C/C++ ;

BTW. Remember to “source /the/location/of/ROOT/bin/thisroot.sh” to add your ROOT executables and libraries to your environment (when ROOT is not installed in some “standard” system locations, like “/usr/[bin|lib]” or “/usr/local/[bin|lib]”).

Now it worked with sourcing like that directly. I thought adding

export ROOTSYS=/opt/ROOT
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib/:$LD_LIBRARY_PATH

to .bashrc is the same thing as source. It is my noobness. Thank you for your time and help.

However I still don’t understand root-config --has-python says no. And also why I don’t have libpyroot.

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