Question

I'm trying to freeze my Python3.2 project and get the following error after running the resulting executable:

Exception raised when calling format_exception. 'str' object has no attribute '__cause__'. Original Exception: cannot import name format.

The project has three internal packages/modules with __init__.py files. It uses external packages: sqlite3, PyQt4, matplotlib, numpy, scipy.

Here is my setup.py:

from cx_Freeze import setup, Executable

includes = ['re', 'PyQt4', 'os', 'scipy', 'csv', 'sqlite3', 'itertools', 'numpy', 'sys', 'matplotlib']
excludes = []
packages = []
path = []

GUI2Exe_Target = Executable(
    # what to build
    script = "xshape_report.py",
    #initScript = None,
    base = 'Win32GUI',
    #targetDir = r"dist",
    #targetName = "xshape_report.exe",
    #compress = True,
    #copyDependentFiles = True,
    #appendScriptToExe = False,
    #appendScriptToLibrary = False,
    icon = None
    )

setup(

    version = "0.1",
    description = "Reporting system",
    author = "Katya",
    name = "Xshape report",

    options = {"build_exe": {"includes": includes,
                             "excludes": excludes,
                             "packages": packages,
                             "path": path
                             }
               },

    executables = [GUI2Exe_Target]
    )

The same error if I leave includes empty. What could be the reason?

Était-ce utile?

La solution

Copying my answer from the mailing list to help other people who search for this:

The 'cannot import name format' bit is some problem with your application. Probably there's some module that it hasn't detected it needs to copy.

It should show more detail about where the error occurs, but there's a bug in cx_Freeze which results in the 'str' object has no attribute '__cause__' message. This is fixed in the development version, so you'll get proper tracebacks if you use that. Hopefully we can have a new release soon.

For people in the future: this problem exists with cx_Freeze 4.2.3, and I guess the release with the fix will be 4.3.0. If you run into this (no attribute '__cause__') with a later version, make sure there's a bug filed for it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top