I have downloaded ROOT via root_v6.32.08.win32.vc17 given on website and have created a virtual environment “C:\32 bit Python for ROOT\venv_root” and I am still not able to import root in python. I am using ‘python 3.13.something’ and I even tried ‘python 3.12.7’.
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Aditya>cd C:\32 bit Python for ROOT
C:\32 bit Python for ROOT>venv_root\Scripts\activate
(venv_root) C:\32 bit Python for ROOT>python --version
Python 3.13.1
(venv_root) C:\32 bit Python for ROOT>python
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 18:47:25) [MSC v.1942 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
import ROOT
ModuleNotFoundError: No module named 'ROOT'
>>>
ROOT Version: 6.32.08 Platform: Windows Compiler: MVSC
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Aditya>"C:\root_v6.32.08\bin\thisroot.bat"
C:\Users\Aditya>C:\32 bit Python for ROOT\venv_root\Scripts\activate
'C:\32' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Aditya>cd C:\32 bit Python for ROOT\venv_root\Scripts\activate
The directory name is invalid.
C:\Users\Aditya>cd "C:\32 bit Python for ROOT\venv_root\Scripts\activate"
The directory name is invalid.
C:\Users\Aditya>cd "C:\32 bit Python for ROOT\"
C:\32 bit Python for ROOT>venv_root\Scripts\activate
(venv_root) C:\32 bit Python for ROOT>python --version
Python 3.13.1
(venv_root) C:\32 bit Python for ROOT>python
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 18:47:25) [MSC v.1942 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
File ←[35m"<python-input-0>"←[0m, line ←[35m1←[0m, in ←[35m<module>←[0m
import ROOT
File ←[35m"C:\root_v6.32.08\bin\ROOT\__init__.py"←[0m, line ←[35m25←[0m, in ←[35m<module>←[0m
import cppyy
File ←[35m"C:\root_v6.32.08\bin\cppyy\__init__.py"←[0m, line ←[35m81←[0m, in ←[35m<module>←[0m
from ._cpython_cppyy import *
File ←[35m"C:\root_v6.32.08\bin\cppyy\_cpython_cppyy.py"←[0m, line ←[35m22←[0m, in ←[35m<module>←[0m
import libcppyy as _backend
←[1;35mImportError←[0m: ←[35mDLL load failed while importing libcppyy: The specified module could not be found.←[0m
←[?25l←[1A
←[?25l←[?25l←[1;35m>>> ←[0m←[4D←[?25h←[4C←[?25l←[?25h←[?25l←[?25h←[4D
←[?25l←[1A
←[?25l←[?25l←[1;35m>>> ←[0m←[4D←[?25h←[4C
you are using Python 3.13.1, but as explained on the ROOT website somewhere: “If you download a binary release, you need to install the exact same Python version used for the compilation of the binary.”
That’s why you get the crash I guess. Sorry if this wasn’t clear. We are making this more explicit in ROOT 6.34 by putting the Python version used at the build into the binary name, e.g. root_v6.34.02.win32.python311.vc17. You can also double check this in out build logs, which indeed say:
2025-01-22T08:04:09.9367575Z -- Looking for Python
2025-01-22T08:04:11.5611302Z -- Found Python3: C:/Python311/python.exe (found suitable version "3.11.7", minimum required is "3.8") found components: Interpreter Development NumPy Development.Module Development.Embed
I hope it will work just fine if you use the suitable Python version.
Ah yes I also tried python 3.11.7 but on using pip list global modules were not shown in the list even though I used --system-site-packages while creating the virtual environment.
I meant that in python 3.11.7 the ROOT problem is still there along with the problems with global packages.
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Aditya>cd "C:\Python 3.11.7 32bit\"
C:\Python 3.11.7 32bit>"C:\Python 3.11.7 32bit\python\python.exe" -m venv --system-site-packages myenv
C:\Python 3.11.7 32bit>myenv\Scripts\activate
(myenv) C:\Python 3.11.7 32bit>python --version
Python 3.11.7
(myenv) C:\Python 3.11.7 32bit>pip list
Package Version
---------- -------
pip 23.2.1
setuptools 65.5.0
[notice] A new release of pip is available: 23.2.1 -> 24.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
(myenv) C:\Python 3.11.7 32bit>
This is what I get with pip list.
And now when I try to import ROOT:
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Aditya>"C:\Python 3.11.7 32bit\myenv\Scripts\activate.bat"
(myenv) C:\Users\Aditya>python --version
Python 3.11.7
(myenv) C:\Users\Aditya>pip list
Package Version
---------- -------
pip 23.2.1
setuptools 65.5.0
[notice] A new release of pip is available: 23.2.1 -> 24.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
(myenv) C:\Users\Aditya>python
Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:13:08) [MSC v.1937 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ROOT'
>>>
And root is present in system environment variables.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\Aditya> root
------------------------------------------------------------------
| Welcome to ROOT 6.34.02 https://root.cern |
| (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for win32 on Dec 15 2024, 07:44:19 |
| From tags/v6-34-02@v6-34-02 |
| With MSVC 19.39.33521.0 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0]
(myenv) C:\Python 3.11.7 32bit>\root_v6.32.08\bin\thisroot.bat
(myenv) C:\Python 3.11.7 32bit>python
Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:13:08) [MSC v.1937 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>>
Probably you need to call thisroot.ps instead of thisroot.bat if you are running from a PowerShell.
Or alternatively changing the VScode default terminal to the cmd one.