Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

python - Getting "ImportError: DLL load failed: The specified module could not be found" when using cx_Freeze even with tcl86t.dll and tk86t.dll added in

I am trying to convert a .py file to .exe using cx_Freeze 5.1.1., but an ImportError: DLL load failed pops up every time I try to run the file. Based on the suggested solutions here and here, I added tcl86t.dll and tk86t.dll to the list of included files. They appear in the build folder, but the error message keeps popping up.

Here is my 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)]
)

I'm using Python 3.6.3 and Windows 10. Any help would be greatly appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In cx_Freeze version 5.1.1, the included modules are in a subdirectory lib of the build directory. The tcl86t.dll and tk86t.dll DLLs apparently need to be moved there as well.

You can do this with the following modification of your 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'))]}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...