Ree*_*ews 10 python tkinter cx-freeze python-3.x
使用cx_Freeze和Tkinter时,我收到消息:
File "C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: DLL load failed: The specified module could not be found.
Run Code Online (Sandbox Code Playgroud)
有些事情需要注意:
这是我目前的setup.py:
from cx_Freeze import setup, Executable
import sys
build_exe_options = {"packages": ["files", "tools"]}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(name="Name",
version="1.0",
description="Description",
options={"build_exe": build_exe_options},
executables=[Executable("main.py", base=base)],
package_dir={'': ''},
)
Run Code Online (Sandbox Code Playgroud)
我从互联网的各个角落尝试了很多解决方案.包括但不仅限于:
将以下内容放在我的编译bat文件中(绝对是正确的路径):
set TCL_LIBRARY=C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35-32\tcl\tcl8.6
set TK_LIBRARY=C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35-32\tcl\tk8.6
Run Code Online (Sandbox Code Playgroud)将以下内容放在我的setup.py中:
options={"build_exe": {"includes": ["tkinter"]}}
Run Code Online (Sandbox Code Playgroud)
include_files = [r"C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35-32\DLLs\tcl86t.dll",\
r"C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35-32\DLLs\tk86t.dll"]
Run Code Online (Sandbox Code Playgroud)
(是的,那些以某种方式包含在setup()中)
感谢您的帮助,非常感谢.是的,我已经在这个网站上查看了这个问题的每个解决方案.希望有人可以帮助我找到另一个解决方案,因为我的问题似乎是持久的.
Ree*_*ews 17
找到了解决方案!
我不得不将我的python目录的DLLs文件夹中的tk86t.dll和tcl86t.dll文件复制到我正在尝试编译的main.py的build文件夹中.
这与,有
set TCL_LIBRARY=C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35\tcl\tcl8.6
set TK_LIBRARY=C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35\tcl\tk8.6
Run Code Online (Sandbox Code Playgroud)
在我的compile.bat的顶部,包括
"include_files": ["tcl86t.dll", "tk86t.dll"]
在setup.py中的build_exe_options中,似乎已经完成了这个伎俩.
这是我目前的setup.py:
from cx_Freeze import setup, Executable
import sys
build_exe_options = {"packages": ["files", "tools"], "include_files": ["tcl86t.dll", "tk86t.dll"]}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(name="Name",
version="1.0",
description="Description",
options={"build_exe": build_exe_options},
executables=[Executable("main.py", base=base)],
package_dir={'': ''},
)
Run Code Online (Sandbox Code Playgroud)
这是我的compile.bat(更新以显示所有步骤):
@echo off
set TCL_LIBRARY=C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6
set TK_LIBRARY=C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6
RD /S /Q "C:\Users\VergilTheHuragok\Desktop\PythonProjectCompiled\bin"
mkdir "C:\Users\VergilTheHuragok\Desktop\PythonProjectCompiled\bin"
xcopy /s "C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python36-32\DLLs\tcl86t.dll" "C:\Users\VergilTheHuragok\Desktop\PythonProjectCompiled\bin\tcl86t.dll"
xcopy /s "C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python36-32\DLLs\tk86t.dll" "C:\Users\VergilTheHuragok\Desktop\PythonProjectCompiled\bin\tk86t.dll"
cd "C:\Users\VergilTheHuragok\Desktop\PythonProject\"
cxfreeze main.py --target-dir "C:\Users\VergilTheHuragok\Desktop\PythonProjectCompiled\bin" --target-name "launch.exe"
pause
Run Code Online (Sandbox Code Playgroud)
我在这里找到了解决方案.
| 归档时间: |
|
| 查看次数: |
8099 次 |
| 最近记录: |