Python in ROOT 6.22

Well, this is a kind of follow-up on the recent “Python3 and ROOT 6.23/01” thread …

This is Ubuntu 20.04 LTS / x86_64 with gcc 9.3.0 and the standard operating system provided python2 2.7.18rc1 and python3 3.8.2 (plus the corresponding numpy versions).

I tried your nightly “root_v6.22.99.Linux-ubuntu20-x86_64-gcc9.3” dated “2020 June 11 23:10 UTC” …

root-config --python-version shows only 3.8.2.

I think it should return a string with both python versions.

root-config --config shows only two python related variables:

Python2_LIBRARY_RELEASE
Python3_LIBRARY_RELEASE

This may be too few … see this thread:

I guess, it would be nice to add:

Python2_INCLUDE_DIR
Python3_INCLUDE_DIR

and possibly also:

Numpy2_INCLUDE_DIR
Numpy3_INCLUDE_DIR

Well, let’s see how the new version behaves …

Some “tutorials/pyroot” macros work in both python versions (e.g. “hsimple.py”, “multifit.py”, “zdemo.py”).
Quite a few are broken and do not work in any (e.g. “demo.py”, “gui_ex.py”, “ratioplot.py”).
Some work with one python version but not with the other one (e.g. “DynamicSlice.py” works in python3 but terribly hangs in python2).

A python2 trial … I click the “Help on Demos” button …

[...]$ python2 demo.py 
enter "q" to quit: input_line_62:1:64: error: redefinition of 'is_equal'
namespace __cppyy_internal { template<class C1, class C2> bool is_equal(...
                                                               ^
input_line_13:1:64: note: previous definition is here
namespace __cppyy_internal { template<class C1, class C2> bool is_equal(...
                                                               ^
input_line_63:1:64: error: redefinition of 'is_not_equal'
namespace __cppyy_internal { template<class C1, class C2> bool is_not_eq...
                                                               ^
input_line_14:1:64: note: previous definition is here
namespace __cppyy_internal { template<class C1, class C2> bool is_not_eq...
                                                               ^
 *** Break *** segmentation violation
(...)

A python3 trial … I click the “Help on Demos” button …

[...]$ python3 demo.py 
enter "q" to quit: Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'execfile' is not defined

BTW. The “demo.py” references nonexistent macros, e.g. “first.py”.

Thanks Wile, this is most probably for @etejedor

Hello Wile,

Thank you for the report.

root-config --python-version shows only 3.8.2.
I think it should return a string with both python versions.
root-config --config shows only two python related variables:
Python2_LIBRARY_RELEASE
Python3_LIBRARY_RELEASE

root-config now returns just the main Python version ROOT was built with, indeed. There is a pending discussion with @oshadura about this. As for the Python variables to show in root-config, @oshadura do we need a similar fix to the one you did for 6.20?

Some “tutorials/pyroot” macros work in both python versions (e.g. “hsimple.py”, “multifit.py”, “zdemo.py”).
Quite a few are broken and do not work in any (e.g. “demo.py”, “gui_ex.py”, “ratioplot.py”).
Some work with one python version but not with the other one (e.g. “DynamicSlice.py” works in python3 but terribly hangs in python2).

I’m aware for demo.py and gui_ex.py, ratioplot.py and DynamicSlice.py work in the nightlies (python2, python3):

http://cdash.cern.ch/testSummary.php?project=1&name=tutorial-pyroot-ratioplot-py&date=2020-06-12
http://cdash.cern.ch/testSummary.php?project=1&name=tutorial-pyroot-DynamicSlice-py&date=2020-06-12

what is the error you see with these two?

The error you show for demo is due to libcppyy being loaded twice, which should not happen, I need to check.

This is now:
https://sft.its.cern.ch/jira/browse/ROOT-10844

First, I haven’t tried all “tutorials/pyroot” macros as I’ve quickly got annoyed by the problems (I only tried these that I explicitly mentioned in my first post here).

python[23] -i ratioplot.py displays a completely empty “canvas”.

python3 -i DynamicSlice.py works o.k. (I think).

python2 -i DynamicSlice.py displays a “Dynamic Slice Example” canvas and as soon as the mouse cursor is moved over this canvas, there appear the same errors as for “python2 demo.py” (see my first post here). What’s worse, it cannot be killed by Ctrl-C nor it reacts to Ctrl-Z and I need to find the PID of this process (in another terminal) and use “kill -9” (yes, “-9” is also needed).

Sorry but, there is no such thing called “main Python version”.
None is “primary” nor “secondary”.
None is “superior” nor “inferior”.
BOTH are equally valid, if ROOT has the support built in.

BTW. I hope you know that “some_canvas_main_menu” → “File” → “Quit ROOT” does completely nothing (in both python versions).

@ajaydeo Try “python2 -i demoshelp.py” and “... | grep -i PYTHON”. :wink:

@Wile_E_Coyote
Thank you. "python2 -i demoshelp.py" works! The canvas stays. It so simple!

How and where to use grep -i PYTHON?
If you mean "root-config --config | grep -i PYTHON", then it still yields nothing!

@Axel I tried your binary release “root_v6.22.00.Linux-ubuntu20-x86_64-gcc9.3” dated “2020 June 14 16:30 UTC” … and … all problems reported in my posts above are still there.

I didn’t expect them to be solved given that https://sft.its.cern.ch/jira/browse/ROOT-10844 isn’t addressed yet. But we should have python2+3 in the binaries - @etejedor could you verify that, please?

Yes, “python2+3 in the binaries” are there. They just do not work as expected, even with the standard “tutorials/pyroot”.

BTW. I think I discovered another python2 problem in ROOT 6.20/06 (possibly unrelated to the new way of python support). I cannot try it in ROOT 6.22/00 due to the bugs shown above.

Hey @etejedor , I thought there was a PR that Massimiliano opened for 6.22?

Just for reference:

I confirm that all the problems mentioned by @Wile_E_Coyote also persist in ROOT v6-23-01-414-gb3ecdf6832 with the following build:

cmake -DCMAKE_INSTALL_PREFIX=/opt/root/dev -DPython3_EXECUTABLE=/usr/bin/python3 -DPython2_EXECUTABLE=/usr/bin/python2 -Dall=ON -Dfortran=OFF -Druntime_cxxmodules=OFF ../root_6.23.01_b3ecdf6

on 64 bit Fedora 32 running cmake version 3.17.3, gcc version 10.1.1 20200507, Python 2.7.18, Python 3.8.3

To give an update, the root-config --config issue with the missing PyROOT variables has been fixed by:

https://github.com/root-project/root/pull/5906 (master)
https://github.com/root-project/root/pull/5928 (6.22)

On the other hand, these PRs by @oshadura made a fix for root-config --python-version to return the highest Python version that PyROOT was built with, and introduced --python2-version and --python3-version:

https://github.com/root-project/root/pull/5893 (master)
https://github.com/root-project/root/pull/5932 (6.22)

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