I’m trying to run a python script but I keep getting a continuous error when simply importing root.
Here’s my code:
print "Importing stuff"
import sys
sys.path.append('C:\root_v5.34.36\bin')
sys.path.insert(1, 'C:\root_v5.34.36\bin') #9/16/16 Added to work on windows?
import optparse
import os
import ROOT
from math import exp, sqrt, log
The two system commands were added to attempt to fix the problem. There error message I’m getting when I try to run the script is
Importing stuff
Traceback (most recent call last):
File "F:\analyze_pulse_shape.py", line 9, in <module>
import ROOT
File "C:\root_v5.34.36\bin\ROOT.py", line 103, in <module>
import libPyROOT as _root
ImportError: DLL load failed: %1 is not a valid Win32 application.
I checked to make sure the libPyROOT DLL was in the C:\root_v5.34.36\bin\ folder and it indeed was. I know that other files in my root directory are fine because I run other root things on my machine but with C++.
I have read some things about the idea that it could be a conflict between 64 bit and 32 bit OS but I’m not confident that is the issue because at one point this code worked on the machine I am using. Also, I am running Windows 7 64 Bit.
This problem is still on going, but I created a work around.
I tried using this on a different windows computer and it worked. All I had to do was copy the libPyROOT.dll and the ROOT.pyc file into the same folder as the python script and it ran.
I still would like to get it working on my original machine however, so any suggestions would be appreciated.
I found the Solution: I was attempting to use 64 bit python on the two windows 7 machines and it wasn’t working. However, on windows 10 I was only using 32 bit python, So I installed 32 bit python on both the windows 7 machines and the error disappears and the code works fabulously.