Packaging PySide applications on Windows

From Qt Wiki
Revision as of 08:44, 16 February 2018 by CristianMaureiraFredes (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Attention: a port of PySide to Qt 5.x started in 2014, the progress and more details about this project can be found under PySide 2


As reported on the mailing list by Srini Kommoori: cx_Freeze area updated: August 21st, 2011 by Andre Mikulec

Here is the process to package your Python scripts.

1. Install cx_Freeze

2. Run:

cxfreeze target-dir dist base-name Win32GUI include-modules atexit,PySide.QtNetwork icon yourapptaskgroup.ico
The result of the cxfreeze statement will create an 'exe' file and supporting files in

"atexit" must be included in —include-modules, otherwise the generated exe will fail.

On Windows, note that the
icon yourapptaskgroup.ico
parameter will insert the icon into the final executable:
. This will be the icon that represents a task bar group that is a stack of applications (and not an individual application). To implement application icons, add statements in your Python PySide code that use the
method. (Yes, this ALSO must be done.)

Currently, I am not sure what the icon behaviors are on OS X and Linux desktops (but they are different than on Windows). If you need to freeze a PySide application on those platforms continue reading the following.

Setting the Application Icon…

3. Copy and replace QtGui4.dll from C:26\Lib\site-packages\PySide to the cxfreeze dist

The issue seems to be caused by cxfreeze pruning dlls. Once original dlls are copied in the distribution directory, everything works as expected. It seems that other DLLs may be causing trouble; just copy them from PySide's directory.

4. To make .gif and .jpg files show in QWebView web pages, do the following:

In the 'dist' directory, create a folder named 'imageformats.' So the result looks like this.


Copy the files found in C:26\Lib\site-packages\PySide\plugins\imageformats into the folder 'dist\imageformats.'

4 ALT. Alternatively, instead of step 4, do all of the following:

4.1.1 In the 'dist' directory, create a folder named 'plugins.' So the result looks like this.


4.1.2 Copy the folders and files found in C:26\Lib\site-packages\PySide\plugins into the folder 'dist\plugins' (and mimic the 'copy' source directory structure within the 'copy' target)

4.1.3 In the dist directory, create a file named 'qt.conf.' So the result looks like this.


4.1.4 In a text editor, open up qt.conf, type into the file the following information.

Binaries = .
Plugins = plugins

4.2 Save the file. Close the text editor.


Following the instructions in the py2exe tutorial works with PySide, with some notes:

  • If you use QtWebKit, QtNetwork must be included manually:

 options = {
 'py2exe': {
 'includes': ['PySide.QtNetwork'],

  • If you use QtNetwork, the target machine must either have OpenSSL installed or the DLLs packaged in the same folder as PySide's DLLs
  • If you use Phonon, the following helps:


Follow the instructions in pyinstaller manual