Building standalone MS Windows apps with py2exe
How to make standalone Windows applications from Python and PyQt4 scripts using py2exe.Building standalone application from Python/PyQt4 scripts under Windows requires py2exe package. When you have it you can build the app using a config file, usualy setup.py. Here is an example config: To build the app run:
python setup.py py2exeWhich will build the application. Sometimes it may stop reporting missing DLLs. Download them from the net and place them in the script folder. If you use Python 2.6 you may need Microsoft Visual C++ 2008 Redistributable Package.
If you try tu run the standalone application and Windows says that the configuration is invalid then you have to install Microsoft Visual C++ 2008 Redistributable Package (note that to app users)
Problem with missing PyQt4 components - QtWebkitIn some cases py2exe wont add all needed libraries. If you use for example QtWebkit, then you will have to manualy add QtNetwork (as its needed by QtWebkit, and not added by py2exe).
Images, icons for my GUIYou should use a Resource file (qrc), and it will be build in into the binary package (as pyrcc4 converts it to a Python file). You don't have add source images to the package.
Standalone application doesn't supports imagesIf you app can display some images and you see nothing (or blue "?" icons), then imageformats DLLs didn't get included. There are two solutions. First is to make a "imageformats" folder in the folder with standalone application, and copy to it all needed DLLs from PyQt4, for example C:\Python26\Lib\site-packages\PyQt4\plugins\imageformats\. The second one - if you use resource file for GUI icons or other things try adding simple (1x1 px even) image of extensions you want to support (If you have only PNGs in resource file, then JPG support may not be available in standalone version. If you add a JPG file to resources - then jpg support should also be added to standalone version).