我试图卡住我的 Python3.2 项目,并在运行生成的可执行文件后收到以下错误:
调用 format_exception 时引发异常。 “str”对象没有属性“__cause__”。 原始异常:无法导入名称格式。
该项目具有三个带有 __init__.py 文件的内部包/模块。它使用外部包:sqlite3、PyQt4、matplotlib、numpy、scipy。
这是我的 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]
)
如果我离开,同样的错误包括空。 可能是什么原因?
最佳答案
从邮件列表中复制我的答案以帮助搜索此内容的其他人:
“无法导入名称格式”位是您的应用程序存在的问题。可能有一些模块尚未检测到需要复制。
它应该显示有关错误发生位置的更多详细信息,但 cx_Freeze 中存在错误,导致 'str' 对象没有属性 '__cause__'
消息。这已在 development version 中修复。 ,所以如果你使用它,你会得到正确的回溯。希望我们能尽快发布新版本。
对于 future 的人:cx_Freeze 4.2.3 存在这个问题,我猜修复后的版本将是 4.3.0。如果您在更高版本中遇到此问题(无属性“__cause__”
),请确保已为其提交了错误。
关于python - cx_卡住错误: 'str' object has no attribute '__cause__' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9989797/