import _tkinter # If this fails your Python may not be configured for Tk

后端 未结 1 1844
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-01 13:19

Some initial information: I have windows 10 on my computer and all programs are 64-bit versions.

I\'m writting a game in python (3.6.1) using tkinter and now I would

相关标签:
1条回答
  • 2020-12-01 13:47

    I had to scour pretty hard to figure this one out for myself. Not sure if this helps anyone but it worked for me. From what I understand these errors are generated when cx_freeze either cannot find all the dependencies or is grabbing incorrect ones.

    First thing I did was to drill down into my python directory. Be VERY careful here and ensure you are looking where your python code is executing. Your IDE may give you this path if you do not know it. In cases of multiple installations or environments you may be off.

    Once in there I identified which file was causing the error. For my situation it was a tkinter dependency. tcl86.dll and tk86.dll were the problem. You can see the lines I added. Then my logo actually started doing it so I had to add that. Now it works great. Here is a sample of my setup.py file (cx_freeze config).

    from cx_Freeze import setup, Executable
    import sys
    import os
    
    includes = []
    include_files = [r"C:\Users\Ace\AppData\Local\Programs\Python\Python36\DLLs\tcl86t.dll",
                     r"C:\Users\Ace\AppData\Local\Programs\Python\Python36\DLLs\tk86t.dll",
                     r"C:\Users\Ace\Desktop\IPNV\KP_App\FML\logo1.gif"]
    os.environ['TCL_LIBRARY'] = r'C:\Users\Ace\AppData\Local\Programs\Python\Python36\tcl\tcl8.6'
    os.environ['TK_LIBRARY'] = r'C:\Users\Ace\AppData\Local\Programs\Python\Python36\tcl\tk8.6'
    base = 'Win32GUI' if sys.platform == 'win32' else None
    
    
    setup(name='KpApp', version='0.9', description='KP Report App',
          options={"build_exe": {"includes": includes, "include_files": include_files}},
          executables=[Executable(r'C:\Users\Ace\Desktop\IPNV\KP_App\FML\firstapp.py', base=base)])
    
    0 讨论(0)
提交回复
热议问题