2

I am trying to convert a pyside app to an executable (.exe) on Windows using cx_freeze. The packaging works with no problem, but when starting the generated .exe file, I get the following error:

ImportError: could not import module "PySide.QtXml"

When I try to convert the app shipped with cx_Freeze\Samples\PyQt4, it runs with no problems.

In this sample application there is just a simple QDialog called, but in my application I used QtDesigner for GUI design and I load it with PySide UiLoader directly in my py.file:

class MainWindow(QtGui.QMainWindow):

def __init__(self,parent=None):
    QMainWindow.__init__(self)
    loader = QUiLoader()
    self.ui = loader.load('xxxx.ui',self)
    QMetaObject.connectSlotsByName(self)

setup.py

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])

import sys
from cx_Freeze import setup, Executable
from PySide import QtXml

base = 'Win32GUI' if sys.platform=='win32' else None

options = {
    'build_exe': {
        'includes': 'atexit'
    }
}

build_exe_options = {
    'includes': ['atexit'],
    }

executables = [
    Executable('xxx.py', base=base)
]

setup(name='xxx',
      version = '0.10',
      description = 'First try',
      options = dict(build_exe = buildOptions),
      executables = executables)

In my opinion there's some problem using UiLoader when converting with cx_freeze but I have no clue how to overcome this issue.

Sabuncu
  • 5,095
  • 5
  • 55
  • 89
eggerra
  • 21
  • 2

1 Answers1

0

This seems to be an old question. Still I am answering as it would help someone who is looking for a solution.

The solution is so simple that you just need to add "PySide.QtXml" to the includes list. After this your setup.py will look like this

build_exe_options = {
    'includes': ['atexit'],
    'packages': ['PySide.QtXml'],
    }
Noortheen Raja
  • 791
  • 11
  • 15