在cx_Freeze进程后找不到Tkinter

时间:2017-09-18 13:24:35

标签: python-3.x tkinter exe cx-freeze

我在剧本的顶部写了下面的内容:

try:
    from Tkinter import *
    from Tkinter import messagebox
except ModuleNotFoundError:
    from tkinter import *
    from tkinter import messagebox
else:
    print("tkinter error")
    input()
    sys.exit()

以.py或.pyw运行我的脚本可以正常运行。但是当我使用cx_Freeze创建和执行.exe时,exe会抛出错误:

enter image description here

那是为什么?怎么解决这个?

...谢谢

编辑: 还有我的setup.py:

import sys
import os
from cx_Freeze import setup, Executable

os.environ['TCL_LIBRARY'] = r"C:\Python\Python36-32\tcl\tcl8.6"
os.environ['TK_LIBRARY'] = r"C:\Python\Python36-32\tcl\tk8.6"

base = None


executables = [Executable("toolbar.py", base=base)]

packages = []
options = {
    'build_exe': {

        'packages':packages,
    },

}

setup(
    name = "Desktop Toolbar",
    options = options,
    version = "1.0",
    description = " ",
    executables = executables
)

0 个答案:

没有答案