exe文件不会运行

时间:2018-01-12 12:04:14

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

我刚刚开始构建我的最终项目,所以想要将其从 .py 转换为 .exe ,看完不同的教程后再使用 cx_Freeze 但仍然在创建 .exe 后,它仍未运行。

import os
os.environ['TCL_LIBRARY'] = r'C:\Program Files (x86)\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files (x86)\Python36-32\tcl\tk8.6'
from cx_Freeze import setup, Executable
setup(name="RMS", version="0.1", description="Your resturant made easy", executables=[Executable(r"C:\Data\Final Project.py")])

1 个答案:

答案 0 :(得分:0)

我猜测它是缺少的tkinter运行时(通常是什么)。您需要使用include_files参数来包含它们:

import os
os.environ['TCL_LIBRARY'] = r'C:\Program Files (x86)\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files (x86)\Python36-32\tcl\tk8.6'
from cx_Freeze import setup, Executable
setup(name="RMS", version="0.1", options = {"include_files": "C:\\Program Files (x86)\\Python36-32\\DLLs\tk86t.dll", "C:\\Program Files (x86)\\Python36-32\\DLLs\tcl86t.dll"}, executables=[Executable(r"C:\Data\Final Project.py")])

另请记住使用\\而不是\。如果需要,您也可以使用/include_files argument here上提到了一个非常短的段落。