Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Package Maker


  • simple pyside
  • multiple packages/modules (third part/yours)
  • non-script resources, suck as icon, image, xml etc

py2app bugs


crash log

Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/  or in the resources directory of your application bundle.

Abort trap


build package with [](

crash log

On Mac OS X, you might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
Segmentation fault


sudo mv  /opt/local/lib/libQtGui.4.dylib ./


loading two sets of Qt binaries


create a empty qt.conf file


load and render image failed


use PIL and convert image into png

py2exe bugs

file not defined

NameError: global name '__file__' is not defined

file doesn't works in package build by py2exe.


def we_are_frozen():
    """Returns whether we are frozen via py2exe.
    This will affect how we find out where we are located."""

    return hasattr(sys, "frozen")

def module_path():
    """ This will get us the program's directory,
    even if we are frozen using py2exe"""

    if we_are_frozen():
        return os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding( )))

    return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( )))

#PWD = os.path.dirname(os.path.realpath(__file__))
PWD = module_path()

ImportError exception

ImportError: No module named gzip
ImportError: No module named dom

缺少什么模块,在 options -> py2exe -> includes 里添加什么模块。

options = {
    "py2exe": {
        "includes": ["PyQt4", "sip", "gzip", "xml.dom.minidom"],
You can’t perform that action at this time.