cx_freeze Tkinter 'Module not Found'

cx_freeze Tkinter 'Module not Found'

我正在尝试从我的 python 脚本创建一个可执行文件。我正在使用 Windows 7、cx_freeze 5.0.2 和 Python 3.6.

我知道 Tkinter 不包含在普通库中,您需要添加类似于以下两行的内容:

os.environ['TCL_LIBRARY'] = "C:\Program Files\Python35\tcl\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\Program Files\Python35\tcl\tk8.6"

当然除了 3.6 和我所在的位置,但是我在 Anaconda 3.6 中找不到他们的目录

我创建了以下名为 setup.py

的文件
import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"]}

# 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 = "McCabe-Thiele",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("GUI.py", base=base)])

和 运行 它来自带有 python setup.py bdist_msi 的 cmd 行。

成功创建 dist,然后成功安装。

然而,当我然后 运行 .exe 发生以下错误时:

ModuleNotFoundError: no module named 'tkinter'

提前感谢您对此的任何帮助

在第三行添加,"includes":["tkinter"]

自动检测依赖关系,但可能需要微调。

build_exe_options = {"packages": ["os"],"includes":["tkinter"]}

当我 运行 它与 python setup.py build

时它对我有用

问题的更新代码:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"],"includes":["tkinter"]}

# 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 = "McCabe-Thiele",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("GUI.py", base=base)])