2017-07-03 71 views
0

我使用cx_freeze将我的py文件转换为.exe。发布时。它给我的错误身份不明的错误。 cx_freeze&tkinter

https://www.upload.ee/image/7186947/Erir.PNG

MY setup.py

from cx_Freeze import setup, Executable 
import os 
import sys 
import os.path 

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__)) 
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR,'tcl','tcl8.6') 
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6') 

setup(
name = "Removed", 
version = "3.5", 
description = "Removed", 
executables = [Executable(script = "test1.py", base = "Win32GUI")]) 
+0

您应该看看这篇文章:https://stackoverflow.com/questions/44845123/convert-tkinter-py-file-into-exe-file/44845504?noredirect=1#comment76671428_44845504 – RyanU

+0

试过,它没有不幸的是, – NoAimNoGame

+0

我看不出你在哪里在安装选项中添加了两个DLL路径,如其他文章所述。 – RyanU

回答

0

您还没有包括TK和您的TCL脚本运行时间。

您应该使用include_files争议来包含它们。

你只需要进行一些修改到你的脚本:

files = {"include_files": ["<Location to Python>/Python36-32/DLLs/tcl86t.dll", "<Location to Python>/Python36-32/DLLs/tk86t.dll"], "packages": ["tkinter"]} 

及用途:

options = {"build_exe": files}, 

,它应该工作。

所以你的脚本应该看起来更像是这样的:

from cx_Freeze import setup, Executable 
import os 
import sys 
import os.path 

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__)) 
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR,'tcl','tcl8.6') 
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6') 
files = {"include_files": ["<Location to Python>/Python36-32/DLLs/tcl86t.dll", "<Location to Python>/Python36-32/DLLs/tk86t.dll"], "packages": ["tkinter"]} 

setup(
name = "Removed", 
version = "3.5", 
description = "Removed", 
options = {"build_exe": files}, 
executables = [Executable(script = "test1.py", base = "Win32GUI")]) 

我希望这有助于。

+0

@NoAimNoGame请看我更新的答案 – Simon