我正在尝试使用 cx_Freeze 5.1.1 将 .py 文件转换为 .exe,但是ImportError: DLL load failed
每次我尝试运行该文件时都会弹出。基于建议的解决方案 here https://stackoverflow.com/questions/42323533/when-using-cx-freeze-and-tkinter-i-get-dll-load-failed-the-specified-module-c and here https://stackoverflow.com/questions/46358961/cx-freeze-import-error-dll-load-failed-tkinter,我将 tcl86t.dll 和 tk86t.dll 添加到包含文件列表中。它们出现在构建文件夹中,但错误消息不断弹出。
这是我的 setup.py:
import sys
import os
from cx_Freeze import setup, Executable
os.environ["TCL_LIBRARY"] = r"C:/Users/Name/AppData/Local/Programs/Python/Python36-32/tcl/tcl8.6"
os.environ["TK_LIBRARY"] = r"C:/Users/Name/AppData/Local/Programs/Python/Python36-32/tcl/tk8.6"
base = "Win32GUI" if sys.platform=="win32" else None
build_exe_options = {"packages": ["winsound", "random", "time", "tkinter", "math"],
"include_files": ['tcl86t.dll',
'tk86t.dll']}
setup(
name = "Game",
author = "Name",
description = "game description",
options = {"build_exe": build_exe_options},
executables = [Executable("game.py", base=base)]
)
我正在使用 Python 3.6.3 和 Windows 10。任何帮助将不胜感激!
In cx_Freeze
版本5.1.1,包含的模块位于子目录中lib
构建目录的。这tcl86t.dll
and tk86t.dll
DLL 显然也需要移到那里。
您可以通过以下修改来做到这一点setup.py
script:
build_exe_options = {"packages": ["winsound", "random", "time", "tkinter", "math"],
"include_files": [('tcl86t.dll', os.path.join('lib', 'tcl86t.dll')),
('tk86t.dll', os.path.join('lib', 'tk86t.dll'))]}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)