[PyQt] Problems using PyQt 4.7 and py2exe

Albert Cervera i Areny albert at nan-tic.com
Thu Mar 11 23:17:20 GMT 2010

A Dijous, 4 de febrer de 2010, Albert Cervera i Areny va escriure:
> If I create the installer for my application using py2exe and PyQt 4.7, the
> application starts but fails with the following exception with QtWebKit:
> ImportError: DLL load failed: Can not find find the specified module.
> The installer works like a charm with PyQt 4.7rc2, though.
> The list of "system" dlls detected by py2exe is different in both versions,
> and considers QtNetwork and QtSvg as system dlls with PyQt 4.7, while it
>  does *not* using rc2.
> Any ideas?

Answering to myself:

The problem seems to be that py2exe thinks QtNetwork.pyd, QtXmlPatterns4.dll 
and QtSvg4.dll from PyQt4.7 are system libraries. The following code has fixed 
the problem for me:

# Override the function in py2exe to determine if a dll should be included
dllList = 
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
    if os.path.basename(pathname).lower() in dllList:
        return 0
    return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

Albert Cervera i Areny
Mòbil: +34 669 40 40 18

More information about the PyQt mailing list