2010-11-05 59 views
1

我想要使用py2exe將基本的tkinter GUI程序轉換爲.exe。但是,我遇到了一個錯誤使用以下轉換腳本。幫助在py2exe中的Tkinter

# C:\Python26\test_hello_con.py py2exe 

from distutils.core import setup 
import py2exe 

setup(windows=[r'C:\Python26\py2exe_test_tk.py']) 

C:\ Python26 \ py2exe_test_tk.py是下面的代碼

import Tkinter as tk 

root = tk.Tk() 
root.title("Test") 


label1 = tk.Label(root,text="Hello!",font=('arial', 10, 'bold'), bg='lightblue') 
label1.pack(ipadx=100, ipady=100) 


root.mainloop() 

這是我的錯誤,當我嘗試運行新創建的.exe

Traceback (most recent call last): 
    File "py2exe_test_tk.py", line 4, in <module> 
    File "Tkinter.pyc", line 1643, in __init__ 
_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    {C:/Users/My_Name/lib/tcl8.5} {C:/Users/My_Name/lib/tcl8.5} C:/Users/lib/tcl8.5 {C:/Users/My_Name/library} C:/Users/library C:/Users/tcl8.5.8/library C:/tcl8.5.8/library 



This probably means that Tcl wasn't installed properly. 

我很確定這是我的轉換腳本中的東西,這給我的問題。我忽略了什麼?或者有人有一個轉換腳本看起來像tkinter GUI程序的例子嗎?也有可能將輸出.exe文件轉移到我的桌面?

編輯:

錯誤報告中說,我是從缺少init.tcl中 {C:/Users/My_name/lib/tcl8.5}。所以我做了那個目錄,並在那裏放了一份init.tcl。現在,當我嘗試運行.exe時,它聲明MSVCR90.dll從我的計算機中丟失,需要運行我的程序。

而且這是蟒蛇2.6.5在Windows 7在Unix世界

+1

這是一個確切的重複http://stackoverflow.com/questions/3964427/py2exe-with-tkinter – 2011-06-07 20:48:41

回答