PyROOT experimental not working in 6.20.06

Dear ROOTers,

I’ve built myself a pyROOT experimental 6.20.06 ROOT mainly in order to be able to use ROOT with python2 and python3 (as I understand, it is not possible with standard pyROOT). There are however 2 problems:

  1. You need to specify explicitly a cmake flag for pyroot experimental to be built, unlike stated in the release notes
  2. Then it doesn’t work here… After import ROOT:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/root/lib/ROOT.py", line 24, in <module>
    import cppyy
  File "/opt/root/lib/cppyy.py", line 61, in <module>
    import libPyROOT as _backend
ImportError: dynamic module does not define module export function (PyInit_libPyROOT)

ROOT Version: 6.20.06
Platform: Fedora 31


For this feature, you need at least ROOT 6.22.

So maybe fix the release notes?

The error you get indicate that you are using the old PyROOT (possibly from another installation). This is likely caused by adding source thisroot.sh somewhere in your bashrc, or by having another ROOT installed somewhere that comes first in your $PATH. On Fedora you can easily use ROOT with both Python 2.x and 3.x, just remove your local installations and do yum install root python2-root python3-root. That will give you ROOT 6.20.06 and both PyROOT for Python 2 and 3. More components can be installed on demand, see https://koji.fedoraproject.org/koji/buildinfo?buildID=1523704 for more details.

Edit: I realize now that only Fedora 30 and below offer this possibility, Matthias stopped building the Python 2.x package for ROOT in Fedora 31, which you use…

Thanks. So, source thisroot.sh in bashrc is a wrong approach in general? Usually I don’t call it, I just set ROOTSYS directory and everything I need works, but here I wanted to try different ROOT versions and this requires sourcing thisroot.sh.

About the Fedora binaries, this is a nice solution, but every now and then I need to test some bugfix from the master. Moreover, for example at the moment the last binary in the repository is 6.20.04 which contains some ugly bugs that make my ROOT software unusable (fine on 6.20.06).

Do you compile yourself or use the binaries from the website? I’m not sure from your reports above. Also, do you have CVMFS mounted?

I compile myself either from source from the ROOT website or from git.

I think I don’t have CVMFS installed, as I don’t know what it is :slight_smile:

Ok, my advice is then to install ROOT’s dependencies using yum, then compile and install like this:

root $ mkdir build && cd build
build $ cmake .. -Drpath=ON -DCMAKE_INSTALL_PREFIX=/opt/root/<version> -CCMAKE_CXX_STANDARD=17 ...
build $ cmake --build .
build $ cmake --build . --target install

After that, rather than source thisroot.sh, just do

export PATH=$PATH:/opt/root/<version>/bin
export PYTHONPATH=$(root-config --libdir)

in the shell where you want to use ROOT, not on your .bashrc. That way you make sure not to mix up different versions of ROOT.

If you need to compile against a specific version of ROOT, use cmake -DCMAKE_PREFIX_PATH=/opt/root/<version> -DCMAKE_C_COMPILER=$(root-config --cc) -DCMAKE_CXX_COMPILER=$(root-config --cxx) ... when configuring your own project.

But I understand that this solution does not compile for two python versions and does not allow for switching between them?

As mentioned above, you need to use the master or v6-22-00-patches branches for multi-python builds.

Thank you. I’ve managed to build master and now I am able to change root versions simply with the ROOT_PYTHON_VERSION variable and then sourcing thisroot.sh

However, now a question: does it work only for pyroot experimental, or also for the standard one?

It seems that pyroot experimental can’t even run the gui_ex.py in the tutorials, not mentioning my software.

If you have issues with new PyROOT and GUIs, you might be hitting this issue. To be sure: does running the script with python -i “fix” it?

python -i doesn’t fix, the error message is the same. Perhaps I should start a separate thread, but here we go:

$ python -i gui_ex.py 
Traceback (most recent call last):
  File "gui_ex.py", line 35, in <module>
    m = ROOT.TPyDispatcher( MyDraw )
  File "/opt/root_master/lib/ROOT/_facade.py", line 163, in _fallback_getattr
    raise AttributeError("Failed to get attribute {} from ROOT".format(name))
AttributeError: Failed to get attribute TPyDispatcher from ROOT

Then with my own software which I run as an executable script, errors are different and not sure if related. They start like this:

input_line_46:9:43: error: base class '::TGMainFrame' has private copy constructor
  Dispatcher1(const Dispatcher1& other) : TGMainFrame(other), m_self(oth...
                                          ^
/home/lewhoo/opt/root_master/include/TGFrame.h:487:4: note: declared private here
   TGMainFrame(const TGMainFrame&);             // not implemented
   ^
/home/lewhoo/workspace/etos/etoswindows/worldmapwindow.py:11: RuntimeWarning: no python-side overrides supported

Alright, this is one for @etejedor :smiley:

Hi,

You are hitting this issue:
https://sft.its.cern.ch/jira/browse/ROOT-10826

I will go back to fix those in the new PyROOT as soon as I can.

Thanks. So for now just to make sure: the python version switching works only for pyroot experimental?

Yes, multi-python is a feature only available for the new PyROOT (default in 6.22) and it requires CMake >= 3.14.

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