[Python/PySide] ImportError on running frozen application with PySide 1.2.0



  • I have a PySide application I'm packaging using cx_freeze. Everything was working great when I was using PySide 1.1.2. However, after upgrading to PySide 1.2.0, the packaged executable always crashes at startup due the following change in PySide.

    In file "__init__.py":https://qt.gitorious.org/pyside/pyside/blobs/master/PySide/init.py.in in the PySide installation directory, a function named _setupQtDirectories is being called unconditionally. Inside the function definition is an import statement that reads

    @from . import _utils@

    It is this line causing the crash because the error message window that popups when the application crashes, states (last few lines from the traceback):

    @
    line 9, in _setupQtDirectories
    from . import _utils
    ImportError: cannot import name _utils
    @

    Note that cx_freeze is including the _utils.py dependency (the script is included in the generated library.zip); I've also tried adding PySide._utils explicitly to cx_freeze's module include list, but that doesn't fix the problem either. I believe the error is because of the use of the relative path in the import statement. When the application is frozen, the interpretation of that relative path probably changes.

    Can someone confirm this is a PySide bug? Or am I doing something wrong? If it's the former, where can I submit a bug report?


    PS:

    For now, I can work around the problem by modifying __init__.py by making the function invocation conditional i.e. change

    @_setupQtDirectories()@

    to

    @
    import sys

    if not hasattr(sys, 'frozen'):
    _setupQtDirectories()
    @

    I'd like to know if there's anything obviously wrong with this work around.

    Regards,
    Ashish.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.