Pyroot not working with pyinstaller

ROOT Version: 6.28/06
Platform: Red Hat 8.5.0-20
gcc Compiler: 8.5.0 (Red Hat 8.5.0-18.0.6)
Python version: 3.6.8

Hello everyone,

I have a strange issue with pyroot. When I execute my .py with the python command like this:


It works fine, but if I compile it with pyinstaller (v 4.10):

pyinstaller --onefile

and run the executable like this:


It doesn’t works and tells me it cannot import the libcppyy3_6:

ImportError: Failed to import libcppyy3_6. Please check that ROOT has been built for Python 3.6

I checked in root/lib and the is there. I don’t understand why it works with the python command but not with the pyinstaller output file. Both “python --version” and “root-config --python-version” give me the same result (3.6.8). It’s like pyinstaller is unable to keep track of the ROOT environment context and I have no idea how to fix that. Any thoughts?

Hi @jgauthier,

welcome to the ROOT forum!

This error is probably only the tip of the iceberg (I can reproduce it by the way, just running pyinstaller on a script that does import ROOT is enough). The pyinstaller only collects the Python dependencies anyway, so is will not be able to bundle the ROOT C++ library. Are you planning to install ROOT on the target systems as well, where you deploy your build?

What is the goal you want to ultimately achieve with that? Maybe there are alternatives, like cloudpickle.

In any case, we for sure can’t make ROOT compatible with pyinstaller in this forum thread here. If you really need it, you can request this compatibility in a feature request on GitHub. However, unless you provide a really strong motivation for this, I don’t think this can be prioritized by the ROOT dev team.


Hi Jonas,

Thank you very much for the reply. All the machines where my code will be running have ROOT installed. But the code also requires TKinter, which might not be installed on every machine and it’s why I thought it would be convenient to have everything bundled in an executable.

But that was really just for convenience purpose. I thought that if there was a simple fix for that it would be great, but since it’s not the case, I will just tell the users to run the code on the computers that have both ROOT and TKinter installed.

Thank you again!

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