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

心已入冬 提交于 2019-11-26 10:02:59

问题


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!


回答1:


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


来源:https://stackoverflow.com/questions/52246748/getting-importerror-dll-load-failed-the-specified-module-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!