【发布时间】:2018-12-18 16:19:03
【问题描述】:
我花了好几个小时试图找到解决这个问题的方法,但我还没有找到任何有用的东西。 所以我正在尝试使用 cx_Freeze 将 tkinter 程序转换为 exe。一切正常,直到我尝试打开实际的 exe 文件 Here's is the error report。
我的设置文件:
import os
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
os.environ['TCL_LIBRARY'] = r"C:\Users\Osborne-Win10\AppData\Local\Programs\Python\Python36\DLLs\tcl86t.dll"
os.environ['TK_LIBRARY'] = r"C:\Users\Osborne-Win10\AppData\Local\Programs\Python\Python36\DLLs\tk86t.dll"
build_options = dict(
packages=['sys'],
includes=['tkinter'],
include_files=[(r'C:\Users\Osborne-Win10\AppData\Local\Programs\Python\Python36\DLLs\tcl86t.dll',
os.path.join('lib', 'tcl86t.dll')),
(r'C:\Users\Osborne-Win10\AppData\Local\Programs\Python\Python36\DLLs\tk86t.dll',
os.path.join('lib', 'tk86t.dll'))]
)
executables = [
Executable('app.py', base=base)
]
setup(name='simple_Tkinter',
options=dict(build_exe=build_options),
version='0.1',
description='Sample cx_Freeze tkinter script',
executables=executables,
)
还有我的脚本:
import tkinter as tk
root = tk.Tk()
tk.Label(root, text='Application', font='Tahoma 15 bold italic').pack()
tk.mainloop()
所以,如果您知道什么可能/导致错误,请告诉我!
【问题讨论】:
标签: python python-3.x operating-system exe cx-freeze