When using cx_Freeze and tkinter I get: “DLL load failed: The specified module could not be found.” (Python 3.5.3)

后端 未结 3 1600
梦如初夏
梦如初夏 2020-12-01 13:15

When using cx_Freeze and Tkinter, I am given the message:

File \"C:\\Users\\VergilTheHuragok\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\tkinter\\__         


        
相关标签:
3条回答
  • 2020-12-01 13:52

    After fixing these issues cx_freeze was still unable to import the dependencies of pandas (namely numpy). To fix this I literally copied and pasted the entire folders into the directory of the .py file I was trying to compile. The executable needs to be in the same directory (so it isn't necessarily stand-alone) but it runs with pandas and numpy.

    0 讨论(0)
  • 2020-12-01 13:58

    Found a solution!

    I had to copy the tk86t.dll and tcl86t.dll files from my python directory's DLLs folder into the build folder with the main.py I was trying to compile.

    This, in conjunction with having

    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
    

    at the top of my compile.bat, and including
    "include_files": ["tcl86t.dll", "tk86t.dll"]
    in my build_exe_options in setup.py, seems to have done the trick.

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

    And here is my compile.bat (updated to show all steps):

    @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  
    

    I found this solution here.

    0 讨论(0)
  • 2020-12-01 14:04

    image

    to solve this problem just copy the files 1.tcl86t.dll 2.tk86t.dll from this path C:\Users\h280126\AppData\Local\Programs\Python\Python36-32\DLLs and placed in our .exe path C:\Users\h280126\PycharmProjects\my_tool\build\exe.win32-3.6 it is working fine :)

    0 讨论(0)
提交回复
热议问题