ImportError: DLL load failed: %1 is not a valid Win32 application

Hello Rooters.

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.

Thank you for your help.

Chris

Hi,

If you right click / Properties on libPyROOT.dll, what does it say about the file type?

What does python --version say?

Cheers, Axel.

These are the file properties.

The python version is python 2.7…

Thanks

Chris




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.

Thanks

Chris Settles

Hi,

Is the python install on the machine where it doesn’t work a 32bit or a 64bit one?

Cheers, Axel.

I have tried it on two windows 7 64 bit machines, and neither of them work. However it does work on a 64 bit Windows 10 Machine.

Do I need to add certain variables to the windows path environment variable possibly?

Thanks

Chris

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.

Thank you for your support.