I have been trying to use cx_freeze for some time now, and yet the same error always occurs
import cx_Freeze.util
ImportError: DLL load failed: %1 is not a valid win32 application
I have tried with both 32 and 64 bit, and have tried both setup.py and cxfreeze.bat
what I am asking is, how do I make it work?
I have had the same problem and this was my solution.
I am using Python 3.2 for windows 64 bit and my library installations were all for 64 bit, including cx_freeze. When I tried to "freeze" a program that imported the PyQt4 package, I got the error:
ImportError: DLL load failed: %1 is not a valid win32 application
In my case, the problem was that the cxfreeze script was copying two DLL files (QtCore4.dll and QtGui4.dll) from my MATLAB installation, rather than from my Python installation. The MATLAB DLLs were 32 bit whereas the Python DLLs were the required 64 bit files.
Read the messages displayed when you run the cxfreeze script to build your exe files. The last few messages should be "copying ...dll-> ....dll". Check the filenames and make sure that all the files are actually being copied from your Python installation and not some other program.
If they are being copied from elsewhere (as in my case) you can simply copy them over yourself after the build. Otherwise, you will have to change your path not to include the folder containing the 32 bit DLLs from whatever program they belong.