I build one code and then created a exe from .py using py2exe .

Now i want to create a self expracted for the same so i used Iexpress to do that . I am able to create the exe from Iexpress but when i try to extract my application from the exe created i get following error :

Traceback (most recent call last):
File "C.py", line 44, in <module>
File "A.pyc", line 4, in <module>
File "PyQt4\QtGui.pyc", line 12, in <module>
File "PyQt4\QtGui.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.

It seems , error is all coming in line :

from PyQt4 import QtCore, QtGui

I saw some ways to fix this on internet but couldnt succeed to fix this . Anyone have any ideas ?

1

There are 1 best solutions below

0
On

I tried to reproduce this here, but it seems to work fine. Here's what I did:

  1. Created a file hello-pyqt.py using this question: How to implement a simple button in PyQt

  2. Created a setup.py:

    from distutils.core import setup
    import py2exe
    
    setup(console=['hello-pyqt.py'],
          options={'py2exe': {'bundle_files': 1,
                              'dll_excludes': ['w9xpopen.exe', 'MSVCP90.dll'],
                              'includes': ['sip']}}
         )
    

    The dll_excludes and includes tricks came from an answer on py2exe fails to generate an executable and this Py2exeAndPyQt page, respectively.

  3. Executed setup.py:

    python setup.py py2exe
    
  4. Tested the output before using IExpress:

    dist\hello-pyqt.exe
    
  5. Bundled it with IExpress in the usual way:

    • Added both hello-pyqt.exe and library.zip.
    • Set the Install Command to hello-pyqt.exe.
    • Enabled Long File Name support.

Compare your process with the one I'm using (above) and see if there's anything that might help. Failing that, I'd use Process Monitor to see which DLL it's failing to load and where it's looking.


The DLLs that are bundled in my library.zip are: QtCore4.dll and QtGui4.dll. You might want to check your library.zip to make sure those files are there.