Differences between revisions 4 and 5
Revision 4 as of 2007-12-25 02:39:37
Size: 1386
Comment:
Revision 5 as of 2007-12-25 02:41:42
Size: 1526
Comment:
Deletions are marked like this. Additions are marked like this.
Line 40: Line 40:
The solution is to add !PyQt4._qt to the setup function (see bellow)
The solution is to add !PyQt4._qt to the setup function (see bellow). I found the solution for the problem [http://www.nabble.com/big-problems-with-py2exe-and-cxfreeze-on-latest-PyQt4-to12048241.html here].

Error message

  File "form1.pyc", line 11, in ?
  File "qt.pyc", line 9, in ?
  File "qt.pyc", line 7, in __load
ImportError: No module named sip

Solution

python setup.py py2exe --includes sip

setup.py

   1 from py2exe.build_exe import py2exe
   2 from distutils.core import setup
   3 setup( console=[{"script": "main.py"}] )

Reference

I found this tips here : http://nerdierthanthou.nfshost.com/2005/03/image-resizer.html

There is a full code sample.

Another Solution to the same problem:

from distutils.core import setup
import py2exe
setup(windows=[{"script":"main.py"}], options={"py2exe":{"includes":["sip"]}})

I found that on the web, unfortunately don't know anymore where, but it also works for me!

Obviously is the second part only a way to get the " --includes sip" parameter directly into the script, but the use of "windows" instead of "console" doesn't open a console window, but immediately a Qt window in my case.

Fix for PyQt4

If you get the following error:

ImportError: No module named _qt

The solution is to add PyQt4._qt to the setup function (see bellow). I found the solution for the problem [http://www.nabble.com/big-problems-with-py2exe-and-cxfreeze-on-latest-PyQt4-to12048241.html here].

   1 from distutils.core import setup
   2 import py2exe
   3 
   4 setup(windows=[{"script" : "app.pyw"}], options={"py2exe" : {"includes" : ["sip", "PyQt4._qt"]}})

Py2exeAndPyQt (last edited 2011-10-16 21:42:58 by MircoAckermann)