key4hep / key4hep-spack

A Spack recipe repository of Key4hep software.
10 stars 23 forks source link

Tutorial - python plotting not working on NAF #534

Closed alaudrain closed 1 year ago

alaudrain commented 1 year ago

After trying the tutorial during the ECFA workshop in Paestum, I had trouble running the final plotting script of the gaudi_alg_higgs part (all the rest worked fine). The error is linked to python plotting backends: (exerpt from the stacktrace)

Traceback (most recent call last):
  File "/nfs/dust/ilc/user/alaudrai/tmp/key4hep-tutorials/gaudi_alg_higgs/setup/higgs_recoil/plotting/plot.py", line 14, in <module>
    fig, ax = plt.subplots(1, 1)

[...]

ModuleNotFoundError: No module named '_tkinter'

Note: this issue seems to be NAF-specific. Running the exact same setup on LXPLUS does work fine.

FYI using the same environment, on NAF (centos7):

>>> mpl.get_backend()
'TkAgg'

while on lxplus (centos7):

>>> mpl.get_backend()
'Qt5Agg'

so it seems NAF and LXPLUS have non-consistent installations...

Maybe related issue: https://github.com/key4hep/key4hep-spack/issues/474


To reproduce:

Follow the steps from key4hep-tutorials #513774d, using key4hep setup "2023-10-06-paestum", ie:

source /cvmfs/sw-nightlies.hsf.org/key4hep/setup-paestum.sh
git clone https://github.com/key4hep/key4hep-tutorials.git
cd key4hep-tutorials/gaudi_alg_higgs/setup

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../install
cmake --build . -t install
cd ../install
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH=$PWD/lib:$PWD/lib64:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=$PWD/include:$ROOT_INCLUDE_PATH
export PYTHONPATH=$PWD/python:$PYTHONPATH
export CMAKE_PREFIX_PATH=$PWD:$CMAKE_PREFIX_PATH
cd ../

wget https://key4hep.web.cern.ch/tutorial/zh_mumu_ild_dst/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402004.Pe2e2h.eR.pL.n000.d_dstm_15090_0.edm4hep.root

sed -i "s;/home/juanmi/.*\.root;rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402004.Pe2e2h.eR.pL.n000.d_dstm_15090_0.edm4hep.root;" higgs_recoil/options/runHiggsRecoil.py
sed -i "s;EvtMax=-1;EvtMax=10000;" higgs_recoil/options/runHiggsRecoil.py
k4run higgs_recoil/options/runHiggsRecoil.py

python higgs_recoil/plotting/plot.py

Frozen env for reference:

source /cvmfs/sw-nightlies.hsf.org/key4hep/releases/2023-10-06-paestum/x86_64-centos7-gcc12.2.0-opt/key4hep-stack/2023-10-07-o4thuq/setup.sh
alaudrain commented 1 year ago

@tmadlener couldn't reproduce the issue neither on NAF nor LXPLUS, both of them returning

>>> mpl.get_backend()
'Qt5Agg'

Solution

Turns out I have a matplotlibrc file forcing the backend to tkAgg; after removing matplotlibrc the plotting part runs fine :)