Dear rooters,
I have a problem with using TExec from a python script, which I use to setup custom color palettes.
A similar issue (also related with TExec) occured to me with the same script some time ago: see Multiple color palettes with python freezes program.
The following dummy script reproduces the problem:
#!/usr/bin/env python
import ROOT
import ctypes
ROOT.gROOT.SetBatch(1)
ROOT.gStyle.SetOptStat(0)
C = ROOT.TCanvas('C', 'C', 500, 500)
xmax = 5.
h1 = ROOT.TH2F('h1', '', 200, -xmax, xmax, 200, -xmax, xmax)
for i in range(0, 100000, 1):
a, b = ctypes.c_double(), ctypes.c_double()
ROOT.gRandom.Rannor(a, b)
h1.Fill(a.value, b.value)
h1.Draw('col')
dt = ROOT.TDatime()
t = ROOT.TText(-0.9 * xmax, 0.9 * xmax, 't')
t.SetTextAlign(13)
t.SetTextSize(.05)
t.SetTextColor(4)
t.Draw()
ex = ROOT.TExec('ex', 'TPython::Exec("dt.Set()");TPython::Exec("t.SetTitle(dt.AsString())")')
ex.Draw()
ROOT.gPad.Update()
C.Print('./texec_problem.pdf')
Error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/delaossa/local/miniconda3/envs/root_base/lib/python3.8/site-packages/ROOT/__init__.py", line 22, in <module>
import cppyy
File "/Users/delaossa/local/miniconda3/envs/root_base/lib/python3.8/site-packages/cppyy/__init__.py", line 60, in <module>
importlib.import_module(libcppyy_mod_name)
File "/Users/delaossa/local/miniconda3/envs/root_base/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
SystemError: initialization of libcppyy3_8 did not return an extension module
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'dt' is not defined
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 't' is not defined
My system is macOS BigSur 11.5.1 and I installed the root_base package with conda:
conda install -c conda-forge root_base=6.24.2=py38hc87488e_0
Python version:
Python 3.8.10 | packaged by conda-forge | (default, May 10 2021, 22:58:09)
[Clang 11.1.0 ] on darwin
The script works just fine on a Linux machine with the same root_base version and python 3.8.10.
Any ideas? Thank you very much!