创建 EXE 时没有基于命名的"Win32GUI"错误cx_freeze



我想将应用程序转换为可执行文件,并为此目的使用cx_freeze。但是我得到了这个错误信息:

......executable.py, line 86, in base
raise ConfigError(f"no base named {name!r}")
cx_Freeze.exception.ConfigError: no base named 'Win32GUI'

版本:win10 Home (x64);Python 3.9.6;Cx_Freeze 6.8;PyQt - 5.15.4;

这很奇怪,因为不久前这段代码工作没有问题?!

import sys
from cx_Freeze import setup, Executable
try:
from cx_Freeze.hooks import get_qt_plugins_paths
except ImportError:
include_files = []
else:
# Inclusion of extra plugins (new in cx_Freeze 6.8b2)
# cx_Freeze imports automatically the following plugins depending of the
# use of some modules:
# imageformats - QtGui
# platforms - QtGui
# mediaservice - QtMultimedia
# printsupport - QtPrintSupport
#
# So, "platforms" is used here for demonstration purposes.
include_files = get_qt_plugins_paths("PyQt5", "platforms")

# base="Win32GUI" should be used only for Windows GUI app
base = None
if sys.platform == "win32":
base = "Win32GUI"
build_exe_options = {
"excludes": [""],
"include_files": include_files,
}
bdist_mac_options = {
"bundle_name": "Test",
}
bdist_dmg_options = {
"volume_label": "TEST",
}
executables = [Executable("main.py", base=base, target_name="TESTS")]
setup(
name="simple_PyQt5",
version="0.3",
description="Sample cx_Freeze PyQt5 script",
options={
"build_exe": build_exe_options,
"bdist_mac": bdist_mac_options,
"bdist_dmg": bdist_dmg_options,
},
executables=executables,
)

找到了解决方案。更新了所有需求(pip´s),然后它就工作了。不知道为什么会这样,但是ok

最新更新