2010-11-17 98 views
1

我試圖將使用.png圖像的GUI程序轉換爲使用py2exe的.exe。它使用PIL來顯示這些圖像。但是,我在轉換時遇到了麻煩。由於某些原因,它使得.exe不會運行。有任何想法嗎?PIL和py2exe的問題

編輯

錯誤:

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



This probably means that Tcl wasn't installed properly. 

的錯誤似乎是完全無關的(如果我做什麼毛病py2exe,這是錯誤我通常會)。一切,工作,直到我導入和使用PIL。另外,我在我的設置文件中包含了PIL。

編輯2

這是顯示我是如何實現圖像的一個片段。

self.image = ImageTk.PhotoImage(Image.open("image.png")) 
self.imageLabel = Tkinter.Label(self, image=self.image) 
self.imageLabel.grid(column=0, columnspan=4, row=0) 
+0

什麼是錯誤?你是否在'setup.py'文件中包含'PIL'模塊? – user225312 2010-11-17 08:15:21

+0

查看我的編輯信息。 – rectangletangle 2010-11-17 08:20:15

回答

1

你怎麼顯示圖像?

也許PIL使用tcl/tk來img.show(),這就是爲什麼你應該在你的py2exe安裝腳本中包含tcl。

+0

請參閱編輯2.我在Tkinter中使用了Image.open()方法。 – rectangletangle 2010-11-17 23:11:04

+0

所以,你是否試圖強制安裝tk/tcl?在py2exe的文檔中有關於它的註釋。 – 2010-11-27 12:09:58

1

萬一有人在發生這個問題,我能夠在我的setup.py文件添加init.tcl中我的「data_files」部分修正此錯誤消息:

setup(data_files=['D:\\Python27\\tcl\\tcl8.5\\init.tcl', 
     windows=["script":'myfile.py')])