3
votes

I ported a PyQt4 application I wrote to PySide but I cannot create an executable file for it. I have attempted to use py2exe, cx_freeze, and PyInstaller to create the exe for PySide, the first two provide similar errors (none provide error reports during build, everything appears good until I try to run the exe) - The PyQt4 version is freezable via py2exe.

System Info

Windows 7, 64 bit - all software are 32-bit versions below packages being used:

  • Python 2.7.3 via Python(x,y) 2.7.3.1
  • Qt 4.8.2
  • PySide 1.1.2
  • NumPy 1.6.2
  • Pywin32 218-1

Exe Conversion Programs

  • PyInstaller 2.0
  • cx_Freeze 4.3.1-1
  • py2exe 0.6.9

py2exe err.Log

Traceback (most recent call last):
File "myApp.pyw", line 11, in <module>
File "PySide\QtGui.pyc", line 12, in <module>

File "PySide\QtGui.pyc", line 10, in __load

ImportError: DLL load failed: The specified procedure could not be found.

cx_freeze err.Log

Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\cx_Freeze\initscript\Console.py",
line 27, in <module>
exex code in m.__dict__
File "myApp.pyw", line 11, in <module>
File "ExtensionLoader_PySide_QtGui.py", line 11, in <module>
ImportError: DLL load failed: The specified procedure could not be found.

FYI: Line11 of MyApp.pyw = from PySide import QtGui, QtCore

PyInstaller err.Log

"The application has failed to start because its side-by-side configuration is 
incorrect. Please see the application event log or use the command-line sxstrace.exe
tool for more detail."

The closest I can find is here but I'm not using that library so I do not think its applicable, nor do I know how to solve that.

Snippet of SxsTrace on the PyInstaller Error

INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32    ",version="9.0.21022.8"

What I have tried

  1. Placed "C:\Python27\Lib\site-packages\PySide" at start of Environment Variables Path

  2. Placed copies of: msvcr90.dll, msvcp90.dll, msvcm90.dll into Python/dll location : I believed msvcp90.dll alone allowed py2exe make a operational PyQt4 exe

  3. Remade all qrc resource file using pyside-rcc

  4. Placed all pyside/dlls into dist folder (py2exe)

  5. ran sxstrace and generated log file on PyInstaller error - not sure what I'm looking for I don't see anything that event viewer or the msgbox didn't already tell me (just more of it)

  6. Reinstalled all python/modules, pyqt, pyside, VSE2008 C++ edition, microsoft SDK, microsoft .netframe work 2.0?, Microsoft Visual C++ 2008 Redistributable Package,

  7. Ported all work in progress modules not needed for package but were in dir

  8. Removed any WIP modules that were not successfully ported/were not hooked up

  9. Copied (manually not setup.py) qt.conf (doesn't seem to exist for pyside only pyqt4?) and plugins to dist folder

1
Have you tried with one of the PySide examples rather than your own application? I just tried the appchooser example using PyInstaller with an almost identical PySide/Qt/Python set up without issue.Austin Phillips
Yeah they work. I'm going to systematically turn each widget into its own exe until I find the problem. Then do this same process on the problem widget by rebuilding it.Steve Lee
Try commenting out the MCF in the .manifiest file: <!--<dependentAssembly> <assemblyIdentity name="Microsoft.VC90.MFC" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" type="win32" version="9.0.21022.8"/> </dependentAssembly>-->frmdstryr

1 Answers

3
votes

I managed to get a working executable using py2exe (somewhat with cx_freeze not at all in PyInstaller). I was able to debug this by converting each module into into stand alone exe's.

  • This managed to reveal errors that could not be replicated otherwise.
  • The main issue for the above errors was from missing converting PyQt4 to PySide in one module

Note this was a data loading module and must have simply missed clicking it while testing my port prior to creating the exe. All other PySide conversions were already done to it.

NB:

from PySide import QtCore, QtGui

Is always required even if your IDE is saying that QtCore is not in use and python runs the module without issues. This is required to make an exe for that module even if you can make it work through Python without QtCore.

This is not actual needed for making the exe of the main window but being able to create an operational exe for the module was helpful.


CONVERSION PROGRAM RESULTS

py2exe - WORKS!

Nothing special just a standard setup.py file works fine.

cx_Freeze

Sort of works, but it behaves erratically and doesn't provide explanations as to why...

I have 3 near identical processes for loading data with the main difference being the files that they load. The one for the smaller file loads fine the larger ones just hang and exit out somewhere before ever running... couldn't even get them to work when putting a msgbox at the front of them.

Similarly I have a dialog that has to retrieve data and do a bit of calculations before show()... it does nothing - no idea why. The main window & most of the program works though.

PyInstaller

I can create exe's for all of the individual modules but not for the main window module. When trying to run it I received the exact same problem that Ticket#590 had except I'm using pywin32-218 & no panda.

When attemptimpting to run this occures: ImportError: No module named pythoncom

Build process indicates: WARNING: pythoncom is changing its name to pythoncom27 WARNING: pywintypes is changing its name to pywintypes27

The really odd part is the module that actually imports from pywin32 can be turned into an operational exe. As can widgets that call this module, but the main window which calls these other widgets give the error.

Second issue with PyInstaller

All stand alone widgets that have reimplemented the close event hang when they are closed.

def closeEvent(self, event):
    self.results.addResultsToDB()
    event.accept()

The above does not occur with py2exe as a stand alone apps.