![](/img/trans.png)
[英]Error on trying to convert a python file into an executable with cx_freeze
[英]Error in opening Python executable file, created using cx_freeze
在问这个问题之前,已经检查了其他查询( 执行文件时为cx_freeze ImportError )与我的问题有关,错误为“ DLL加载失败”,但我的情况为“未命名模块”。
我的问题是-我已经使用cx_freeze创建了Python可执行文件,但是当我打开Main.exe文件时,应用程序将打开并带有Traceback错误。
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
"optimize": 2,
"includes": [],
"compressed": True,
"copy_dependent_files": True,
"create_shared_zip": False,
"append_script_to_exe": True,
"include_in_shared_zip": False,
"include_files":[('vPlot.ui'),
('vPlot.py'),
('company.jpg')],
"include_msvcr": True,
"packages": [],
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "plcTest",
description = "plcTest!",
options = {"build_exe": build_exe_options},
executables = [Executable("Main.py",
base=base,
copyDependentFiles=True,
appendScriptToExe=True)])
我的错误是( http://i.imgur.com/TSVg6Ft.png ),我找不到文件“'matplotlib.backends.backend_tkagg'”,请提供建议,谢谢。
cx-freeze具有很好的模块分析能力,但有时会失败。 特别是背面和模块。
Matplotlib使用tkagg (我不确定它是软件包名称)作为后端gui模块。 要解决此问题,您有两个选择;
1-在您的代码中的某处导入丢失的软件包
2-将软件包名称传递给cx-freeze作为参数。
示例:我从命令行使用了cx-freeze
cxfreeze FooMain.py --include-module=simplejson, lxml # FooMain.py my main script
编辑:使用python build_exe_options
"packages": ["simplejson", "lxml"],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.