Hello,
I am trying to use ROOT in python on Windows 7. I installed python 2.7.1, and ROOT 5.28.00 (prebuilt Windows binaries for both). Per instructions on the ROOT website (root.cern.ch/drupal/content/how- … nterpreter), I set the following environment variables as suggested:
set PATH=%ROOTSYS%/bin;%PATH%
set PYTHONPATH=%ROOTSYS%/bin;%PYTHONPATH%
However, when I try to import ROOT from within python, I get an error saying no ROOT module is found. I can’t run any of the python demos either.
What am I doing wrong? Do I need to compile ROOT from scratch to be able to use ROOT classes from within python? Is python support not available in the prebuilt windows binaries? Most likely I am missing something obvious here.
in python, you can look at sys.path (“import sys; print sys.path”) to see whether the paths are properly picked up. It makes a difference (in back- v.s. forward- slashes) whether you use a version of python build for windows, or the cygwin ones. Other than that, I thought that the downloadable binaries are build for p2.6.5.
assuming that $ROOTSYS = C:\root that should be okay. (And assuming that you build ROOT locally with that version of python.) Does the directory C:\root\bin contain ROOT.py and libROOT.pyd?
And, I did not build root locally. I just downloaded the windows binary for ROOT 5.28.00. That was part of my original question – is it necessary to build ROOT from source with certain specific configuration options o be able to use it within python? I would have though python support should be automatic, even for the binaries, and one of your posts in this thread seemed to suggest that?
as said, the downloadable binaries are going to require p2.6.5, not p2.7. But even that still isn’t going to help unless ROOT.py and libROOT.pyd can be located … I’m not all that familiar with Windows and do not currently have access to a Windows box. Are ROOT.py and libPyROOT.pyd in $ROOTSYS/lib?
I’ve had the same problem.
Seems like those prebuilt (*.msi) packages are broken and do not contain the necessary files for PyROOT.
What I did was simply download the .tar.gz ones and replace the contents of my ROOT installation directory with those.
C:\Users\bellenot\DAQ>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>>
C:\Users\M. Gonzalez Alvarez>python
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:04:37) [MSC v.1929 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'
My ROOT version is 6.24/00. Can you tell me please which version of ROOT are you using? In fact, the issue may be caused by the ROOT installation, which encourages me even more to ask you the version you are using
Thank you Bellenot, that confirms that the issue is with my root6 on w10. I also found another post having the same issue of me (Looks like I have to abandon Root on Windows), so this may mean that I should continue with my virtual machine with Linux and fine .
Thank you so much for your help bellenot, it was useful to me and I am sure it will also be to many users :))))
C:\Users\M. Gonzalez Alvarez>root
RegOpenKeyEx(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\$VERSION\InstallationFolder): returned 2: The system cannot find the file specified.
RegOpenKeyEx(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots\KitsRoot10): returned 2: The system cannot find the file specified.
input_line_1:1:10: fatal error: 'new' file not found
#include <new>
^~~~~
Replaced symbol atexit cannot be found in JIT!
Replaced symbol at_quick_exit cannot be found in JIT!
Replaced symbol __dllonexit cannot be found in JIT!
Replaced symbol _onexit cannot be found in JIT!
input_line_3:37:10: fatal error: 'string' file not found
#include <string>
^~~~~~~~
------------------------------------------------------------------
| Welcome to ROOT 6.24/00 https://root.cern |
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for win32 on Apr 14 2021, 14:33:50 |
| From tags/v6-24-00@v6-24-00 |
| With MSVC 19.23.28107.0 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
input_line_7:1:10: fatal error: 'iostream' file not found
#include <iostream>
Still, root opens, but if typing something such as new TBrowser, it does not work:
root [0] new TBrowser
IncrementalExecutor::executeFunction: symbol '?gCling@runtime@cling@@3PAVInterpreter@2@A' unresolved while linking [cling interface function]!
You are probably missing the definition of class cling::Interpreter * cling::runtime::gCling
Maybe you need to load the corresponding shared library?
root [1]
So, I assume this is the reason why import ROOT does not work, somehow ROOT is not correctly installed. I only downloaded the .zip, and did what you do.
I have installed Python 32 bits since ROOT is 32 bits, but my problem seems to be related with ROOT instead.
Do not untar in a directory with a name containing blank characters.
So C:\Users\M. Gonzalez Alvarez\ will not work.
Then, you need Visual Studio to be installed on your system, otherwise the interpreter will not find the c++ header files (as you can see).
And, again, the bat files is properly called but when typing root the same issue appears.
I have Microsoft Studio Community 2019 installed (root 6.24 requires Windows Visual Studio 2019), so that should be fine (community version simply because that version is free ). Could that be the issue, I need another version?