2017-02-19 70 views
0

我試圖創建一個使用cx_Freeze從我的Python項目的可執行文件,但繼續運行這個錯誤:使用cx_Freeze創建可執行文件(無法導入_tkinter,DLL加載失敗)

enter image description here

這裏是我的設置的.py:

import cx_Freeze 
import os, sys 

os.environ['TCL_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tcl8.6" 
os.environ['TK_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tk8.6" 

base = None 
if sys.platform == "win32": 
    base = "Win32GUI" 

executables = [cx_Freeze.Executable("Main.pyw", base=base)] 
includes  = ["tkinter"] 
include_files = [r"D:\Code\Python\3.5.2\tcl\DLLs\tcl86t.dll", \ 
       r"D:\Code\Python\3.5.2\tcl\DLLs\tk86t.dll"] 

cx_Freeze.setup(
    name="Test", 
    version = "1.0", 
    options={"Test.exe": {"packages":["pygame", "numpy"], "includes": includes, "include_files": include_files}}, 
    executables = executables) 

我試圖把tkinter在「包」列表中,但仍然得到同樣的錯誤。我也檢查了其他的StackOverflow帖子,並將他們setup.py代碼的部分代碼加入我的代碼中,但沒有任何工作。我不能使用PyInstaller,因爲它不支持pygamepy2exe不支持Python 3.5。任何幫助,將不勝感激。

回答

0

將文件(tcl86t.dll,tk86t.dll)複製並粘貼到exe.win。 它爲我工作。

相關問題