我使用cx_freeze将我的py文件转换为.exe。在发布时。它给了我错误
https://www.upload.ee/image/7186947/Erir.PNG
我的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 :(得分: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")])
我希望这会有所帮助。