2017-02-19 3 views
4

은, 내가 메시지를 부여하고 (파이썬 3.5.3) :cx_Freeze 및 tkinter를 사용할 때 "DLL로드 실패 : 지정한 모듈을 찾을 수 없습니다." 나 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. 

몇 가지주의해야 할 :

  • 나는 3+ 파이썬을 사용하려면 (현재 3.5을 사용하여. 3, 32 비트). 실제로 작동하는 특정 버전은 신경 쓰지 마십시오.
  • 내 프로젝트에 컴파일해야하는 파일이 여러 개 있습니다. 내가 말할 수있는 한, 그것은 cx_Freeze 나 Nuitka로 나를 떠난다. Nuitka는 자체적으로 문제가있었습니다.
  • 나는 윈도우 10 홈 에디션, 64 비트를 사용하고

여기에 내 현재 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={'': ''}, 
    ) 

가. 를 포함하되 이에 국한되지 :에는 EasyGUI으로 Tkinter를 교체

  • 파이썬의 여러 버전 (및 해당 나 cx_Freeze/Tkinter를 버전)
  • 32 비트 및 64 비트 두 버전
  • (명백하게에는 EasyGUI가 Tkinter의 필요 작업)
  • 내 컴퓨터 (내가 기대했던 몰라)
  • 를 다시 시작 경로 변수
  • 확인 파이썬의 다른 버전을 제거하고 올바른 버전을 복구
  • 내 컴파일 박쥐 파일에서 다음 (의 definetly 올바른 경로) 배치 :

    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"] 
,210

(그리고 그래, 그가 어떤 식 으로든에서 설정()에 포함 된) 어떤 도움


덕분에, 그것은 크게 감사합니다. 그리고 네, 저는이 사이트에서이 문제에 대한 모든 해결책을 살펴 보았습니다. 누군가가 내 문제가 영구적 인 것 같아서 또 다른 해결책을 찾을 수 있도록 도와 줄 수 있길 바란다.

답변

5

해결책을 찾았습니다!

필자는 python 디렉토리의 DLL 폴더에서 tk86t.dll 및 tcl86t.dll 파일을 컴파일하려고하는 main.py가있는 빌드 폴더에 복사해야했습니다.내 compile.bat의 상단에

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 

을 가진, 그리고 setup.py 내 build_exe_options에서
"include_files": ["tcl86t.dll", "tk86t.dll"]
등과 함께

은 트릭을 할 것으로 보인다. 여기

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 

내가이 솔루션 here 발견이

여기에 내 현재 setup.py입니다.

+0

답변의 파이썬 버전과 원래 게시물 사이의 불일치를 무시하십시오. 이 솔루션을 찾기 전에 여러 가지 버전을 시도했습니다. 버전이 문제라고 생각하지 않습니다. – VergilTheHuragok

관련 문제