2015-10-23 49 views
10

我使用py2app 0.9Mac OSX Yosemite 10.10.1從蟒蛇分佈和Tcl 8.5運行Python 3.4py2app建立確定,但應用程序失敗,「_tkinter.TclError」(並沒有錯誤信息!)

在早期的嘗試,構建會失敗,但快速搜索揭示這些問題的解決方案(即包括「包」:['tkinter', 'matplotlib']在選項setup.py,並改變MachOGraph.py線49:裝載機 - > loader_path)

現在py2app完成構建,並在別名模式下運行我的應用程序的功能,但是當我建立在正常模式(蟒蛇setup.pypy2app)所產生的應用程序將無法打開,並且控制檯顯示以下追蹤:

回溯(米OST最後調用):文件 「/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/ 啓動 py」 爲, 線355,在_run()文件 「/用戶/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/ boot .py「, line 336,in _run exec(compile(source,path,'exec'),globals(), globals())文件 「/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/deani.py」, line 731,in app = fishingapp()文件 「/ Users/ryankeenan /Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/deani.py「, 行536,在init tk.Tk. init(self,* args,** kwargs)文件 「/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/lib/python3.4/tkinter/ init .py 」, 線1851,在INIT self.tk = _tkinter.create(屏幕名,baseName的, 的className,交互,wantobjects,useTk,同步,使用) _tkinter.TclError

令人沮喪的是,它不會打印「_tkinter.TclError」的任何錯誤消息。我搜索了很多,未能找到任何解決方案或複製這個問題。我嘗試過構建各種基於tkinter的應用程序,它們都以相同的方式失敗。

這是第一次打電話給tk.Tk。 init(self,* args,** kwargs)在我的代碼中。

我的setup.py文件看起來是這樣的:

from setuptools import setup 
APP = ['deani.py'] 
DATA_FILES = [] 
OPTIONS = {'packages': ['tkinter','matplotlib'],'argv_emulation': True} 
setup( 
    app=APP, 
    data_files=DATA_FILES, 
    options={'py2app': OPTIONS},  
    setup_requires=['py2app'],) 

回答

0

我是有這個問題,並發現它是由於版本衝突在/Library/Frameworks的Tcl/Tk的。檢查構建的輸出(確保先刪除舊的構建)以引用不同版本的tcl/tk。我發現當前版本的tcl/tk是py2app連接的8.6版本,但同時py2app正在從tcl/tk 8.5複製文件。我通過從`/Library/Frameworks/(Tcl/Tk).framework/Versions中刪除8.5來解決這個問題。

注:我不會建議刪除版本,除非您在構建輸出中看到問題並且知道沒有其他任何(您關心的)依賴於該版本。

但是,這不是我唯一的錯誤,因爲當我刪除舊版本時,我發現了一個新的_tkinter.Tcl錯誤,它指向我的代碼中的錯誤。如果你想查看回溯而不必去控制檯,我建議在你的起始代碼周圍放置一個try/except語句,它將回溯打印到一個文件中。例如:

 import sys, time, traceback  
     try: 
      run()#Your opening code goes here 
     except: 
      with open('/Path/to/somewhere/tb.txt','a') as file: 
       y,mn,d,h,m,s,a,b,c = time.localtime() 
       file.write("==================="+str(mn)+'/'+str(d)+' '+ 
          str(h)+':'+str(m)+':'+str(s)+ 
          "=====================\n") 
       traceback.print_exc(file=file) 

希望這對我有所幫助。

相關問題