gpt4 book ai didi

python - 使用 cx_Freeze 时获取 "ImportError: DLL load failed: The specified module could not be found",即使添加了 tcl86t.dll 和 tk86t.dll

转载 作者:太空宇宙 更新时间:2023-11-04 02:17:50 24 4
gpt4 key购买 nike

我正在尝试使用 cx_Freeze 5.1.1 将 .py 文件转换为 .exe,但每次我尝试运行该文件时都会弹出 ImportError: DLL load failed。基于建议的解决方案 herehere ,我将 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。非常感谢任何帮助!

最佳答案

cx_Freeze 版本 5.1.1 中,包含的模块位于构建目录的子目录 lib 中。 tcl86t.dlltk86t.dll DLL 显然也需要移动到那里。

您可以通过对 setup.py 脚本进行以下修改来完成此操作:

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'))]}

关于python - 使用 cx_Freeze 时获取 "ImportError: DLL load failed: The specified module could not be found",即使添加了 tcl86t.dll 和 tk86t.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52246748/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com