Hello,
I have issues making pyROOT work on my installation.
Due to unlucky circumstances I have to work on a Windows 11 - 64 bit system and I fear this may change some things that are not documented.
In short, the problematic error message I get is:
>>> import ROOT
ModuleNotFoundError: No module named 'libcppyy3_11'
During handling of the above exception, another exception occurred:
ImportError: Failed to import libcppyy3_11. Please check that ROOT has been built for Python 3.11
Since the pre-compiled binaries didn’t work (they used Python 3.8 if I remember correctly); I attempted to compile it myself.
Here is the procedure I followed:
- Install all listed dependencies
- Newest CMake form linked Website
- Newest Visual Studio Code from linked Website (Community Edition)
- Python was already installed (3.11.2 - see post footer for full version)
- Clone the root repository from Github
- Checkout the tag
v6-28-04
- Create new directories
install_dir
andbuild_dir
in a path without spaces and set the corresponding variables,source_dir
being the cloned repo itself. - Compile (PowerShell 7.3.4):
cmake -G"Visual Studio 17 2022" -A x64 -Thost=x64 -DCMAKE_INSTALL_PREFIX=$install_dir $source_dir
cmake --build . --config Release --target install
- Move into
bin
subfolder:cd $install_dir/bin
(PowerShell) - Execute
thisroot.ps1
:thisroot.ps1
(PowerShell) - (Start Python and try to import the package)
The compilation seems to have worked and I watched it the whole time, catching only WARN errors relevant to type-conversion. I have stored examples of those and could share them if needed.
Additional things I have tried:
- Execute root. This works fine!
- Add the user environment variable
PYTHONPATH
with the value<install_dir>\bin
. - Add the path
<install_dir>\bin
to user’s PATH. - Restart the Computer
- Run
thisroot.bat
inside a “x64 Native Tools Command Prompt for VS 2022” and start python there. - Read the hundreds of others posts with the same error message, but apparently other causes for it.
- Try and find the file (using the Debian-WSL):
cd root_v6.28.04_py3.11 # (install_dir)
find . -name '*cppyy*'
./bin/cppyy
./bin/cppyy/_cpython_cppyy.py
./bin/cppyy/_pypy_cppyy.py
./bin/cppyy_backend
./bin/cppyy_backend/_cppyy_generator.py
./bindings/pyroot/cppyy
./bindings/pyroot/cppyy/cppyy
./bindings/pyroot/cppyy/cppyy-backend
./bindings/pyroot/cppyy/cppyy-backend/cppyy_backend3_11.dir
./bindings/pyroot/cppyy/cppyy-backend/cppyy_backend3_11.vcxproj
./bindings/pyroot/cppyy/cppyy-backend/cppyy_backend3_11.vcxproj.filters
./bindings/pyroot/cppyy/CPyCppyy/cppyy3_11.dir
./bindings/pyroot/cppyy/CPyCppyy/cppyy3_11.vcxproj
./bindings/pyroot/cppyy/CPyCppyy/cppyy3_11.vcxproj.filters
Things I haven’t tried:
- Other compilation options/flags
Weird things I noticed in my attempts:
- Compilation ignored the
install_dir
directive, so I ended up using the same folder forinstall_dir
andbuild_dir
. - Compilation fails more or less silently if any of the
*_dir
includes spaces in its path (it prints fatal error messages but does not stop and if I miss those, nothing hints at the errors in the last logged lines of execution).
Full Error behavior:
❯ python
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
File "C:\ProgramShares\root_v6.28.04_py3.11\bin\cppyy\__init__.py", line 60, in <module>
importlib.import_module(libcppyy_mod_name)
File "C:\Users\utrfh\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'libcppyy3_11'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramShares\root_v6.28.04_py3.11\bin\ROOT\__init__.py", line 25, in <module>
import cppyy
File "C:\ProgramShares\root_v6.28.04_py3.11\bin\cppyy\__init__.py", line 62, in <module>
raise ImportError(
ImportError: Failed to import libcppyy3_11. Please check that ROOT has been built for Python 3.11
I will now attempt to install it in the WSL in the hopes that this will do. Therefore, in the hope that we can find a solution, this post is also meant as a log of my attempts for others to cross-check any difficulties they may have.
Thank you for reading so far.
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.28.04
Platform: Windows 11 - 64 bit
Compiler: cmake (“Visual Studio 17 2022”)
Python Version: 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32