2010-11-05 73 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

回答