您的位置:首頁技術文章
文章詳情頁

當使用cx_Freeze和tkinter時,我得到:“ DLL加載失?。赫也坏街付ǖ哪K?!?(Python 3.5.3)

瀏覽:3日期:2022-08-07 10:50:06
如何解決當使用cx_Freeze和tkinter時,我得到:“ DLL加載失?。赫也坏街付ǖ哪K?!?(Python 3.5.3)?

找到了解決方案!

我必須將tk86t.dll和tcl86t.dll文件從python目錄的DLLs文件夾復制到帶有嘗試編譯的main.py的build文件夾中。

這與

set TCL_LIBRARY=C:UsersVergilTheHuragokAppDataLocalProgramsPythonpython35tcltcl8.6 set TK_LIBRARY=C:UsersVergilTheHuragokAppDataLocalProgramsPythonpython35tcltk8.6

在我的compile.bat的頂部,以及'include_files': ['tcl86t.dll', 'tk86t.dll'] 在setup.py的build_exe_options中,似乎已經解決了這個問題。

這是我當前的setup.py:

from cx_Freeze import setup, Executable import sysbuild_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={’’: ’’}, )

這是我的compile.bat(已更新以顯示所有步驟):

@echo offset TCL_LIBRARY=C:UsersVergilTheHuragokAppDataLocalProgramsPythonpython36-32tcltcl8.6set TK_LIBRARY=C:UsersVergilTheHuragokAppDataLocalProgramsPythonpython36-32tcltk8.6RD /S /Q 'C:UsersVergilTheHuragokDesktopPythonProjectCompiledbin'mkdir 'C:UsersVergilTheHuragokDesktopPythonProjectCompiledbin'xcopy /s 'C:UsersVergilTheHuragokAppDataLocalProgramsPythonpython36-32DLLstcl86t.dll' 'C:UsersVergilTheHuragokDesktopPythonProjectCompiledbintcl86t.dll'xcopy /s 'C:UsersVergilTheHuragokAppDataLocalProgramsPythonpython36-32DLLstk86t.dll' 'C:UsersVergilTheHuragokDesktopPythonProjectCompiledbintk86t.dll'cd 'C:UsersVergilTheHuragokDesktopPythonProject'cxfreeze main.py --target-dir 'C:UsersVergilTheHuragokDesktopPythonProjectCompiledbin' --target-name 'launch.exe'pause解決方法

當使用cx_Freeze和Tkinter時,出現以下消息:

File 'C:UsersVergilTheHuragokAppDataLocalProgramsPythonPython35-32libtkinter__init__.py',line 35,in <module>import _tkinter # If this fails your Python may not be configured for TkImportError: DLL load failed: The specified module could not be found.

注意事項:

我想使用Python 3+(當前使用3.5.3,32位)。不管實際如何,都不在乎特定版本。我的項目有多個文件需要編譯。據我所知,這讓我留下了cx_Freeze或Nuitka。努伊特卡有自己的問題。我正在使用Windows 10家庭版64位

這是我當前的setup.py:

from cx_Freeze import setup,Executable import sysbuild_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={’’: ’’},)

我已經嘗試了來自互聯網各個角落的許多解決方案。包括但不僅限于:

多個版本的python(以及相應的cx_Freeze / Tkinter版本)32位和64位版本用easygui替換Tkinter(顯然easygui需要Tkinter來工作)檢查PATH變量重新啟動計算機(不知道我的期望)卸載其他版本的python并修復正確的版本

將以下內容放入我的編譯bat文件(正確的路徑):

set TCL_LIBRARY=C:UsersVergilTheHuragokAppDataLocalProgramsPythonPython35-32tcltcl8.6

set TK_LIBRARY=C:UsersVergilTheHuragokAppDataLocalProgramsPythonPython35-32tcltk8.6

在我的setup.py中放置以下內容:

options={'build_exe': {'includes': ['tkinter']}}

隨著:

include_files = [r'C:UsersVergilTheHuragokAppDataLocalProgramsPythonPython35-32DLLstcl86t.dll', r'C:UsersVergilTheHuragokAppDataLocalProgramsPythonPython35-32DLLstk86t.dll']

(是的,這些以一種或另一種方式包含在setup()中)

感謝您的幫助,我們將不勝感激。是的,我已經在該站點上查看了針對該問題的幾乎所有解決方案。希望有人可以幫助我找到另一種解決方案,因為我的問題似乎一直存在。

標簽: Python 編程
国产综合久久一区二区三区