Py2exe ImportError: No module named sip

Source: Internet
Author: User

Simple Solution: c: \ Python26 \ python.exe setup. py py2exe -- extends des sip

 

It is very convenient to use pyqt to complete the form interface, but there will be problems after packaging it into exe. The solution on the internet is as follows:

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!

Obviusly 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 here.

Switch row number display

   1 from distutils.core import setup
2 import py2exe
3
4 setup(windows=[{"script" : "app.pyw"}], options={"py2exe" : {"includes" : ["sip", "PyQt4._qt"]}})
 
Official solution:
http://www.py2exe.org/index.cgi/Py2exeAndPyQt
Official pyexe manual:
http://www.py2exe.org/index.cgi/Tutorial#Step1

ImportError: No module named sip2009-11-07

Error message

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

Solution

Python setup. py py2exe -- extends des sip

Setup. py

Toggle line numbers

   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 setupimport py2exesetup(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!

Obviusly 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 here.

Toggle line numbers

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

Using PyQt4 with Databases

When deploying applications which use PyQt4 and
SQLite:

  • Add "PyQt4.QtSql'
    To the setup events des.

  • Copy the contents of PyQt4 \ plugins \ sqldrivers
    To <appdir> \ sqldrivers. It did not work for me in any subdirectory including the zipfile directory. For SQLite I only needed to copy qsqlite4.dll.

  • A separate copy of sqlite3.dll is not needed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.