When using cx_Freeze and tkinter, I get: "Error loading DLL: the specified module was not found." (Python 3.5.3)

When using cx_Freeze and Tkinter, I get the message:

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.

Some notes:

  • I want to use Python 3+ (currently using 3.5.3, 32-bit). Actually, the specific version does not care, no matter what works.
  • There are several files in my project that I need to compile. As far as I can tell, this leaves me with cx_Freeze or Nuitka. Nuitka had its problems.
  • I am using Windows 10 Home Edition, 64-bit

Here is my current 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={'': ''},  
      )

I have tried many solutions from all over the Internet. Including but not limited to:

  • Multiple versions of python (and corresponding versions of cx_Freeze / Tkinter)
  • Both 32-bit and 64-bit
  • Tkinter easygui (, easygui , Tkinter )
  • PATH
  • ( , )
  • python
  • bat 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
    
  • setup.py :

    options={"build_exe": {"includes": ["tkinter"]}}
  • :
    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"]

( , setup() )


, . , . , - , .

+4
1

!

tk86t.dll tcl86t.dll DLL python main.py, .

,

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

.bat, "include_files": ["tcl86t.dll", "tk86t.dll"]
build_exe_options setup.py, , .

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={'': ''},  
    )  

compile.bat:

@echo off
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
cxfreeze "C:\Users\VergilTheHuragok\PythonProjects\Name\main\main.py" --target-dir "C:\Users\VergilTheHuragok\Desktop\CompiledPythonProjects\build" --target-name "launch.exe"
pause  

.

+6

Source: https://habr.com/ru/post/1670204/


All Articles