I am using py2app 0.9
on Mac OSX Yosemite 10.10.1
running Python 3.4
from the anaconda distribution and with Tcl 8.5
.
In earlier attempts, the build would fail, but quick searches revealed solutions to these problems (i.e. including 'packages': ['tkinter', 'matplotlib']
in OPTIONS in setup.py
, and changing line 49 of MachOGraph.py
: loader --> loader_path)
Now py2app
finishes the build, and running in Alias mode my app functions, but when I build in normal mode (python setup.py
py2app
) the resulting app will not open and the console shows the following traceback:
Traceback (most recent call last): File "/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/boot.py", line 355, in _run() File "/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/boot.py", line 336, in _run exec(compile(source, path, 'exec'), globals(), globals()) File "/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/deani.py", line 731, in app = fishingapp() File "/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/deani.py", line 536, in init tk.Tk.init(self, *args, **kwargs) File "/Users/ryankeenan/Desktop/fishing/gui_test/dist/deani.app/Contents/Resources/lib/python3.4/tkinter/init.py", line 1851, in init self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError
The frustrating thing is that it doesn't print any error message for "_tkinter.TclError". I've searched quite a bit and failed to find any solutions or replications of this problem. I've tried building various tkinter based apps and they all fail in the same way.
This is occurring at the first call to tk.Tk.init(self, *args, **kwargs) in my code.
My setup.py file looks like this:
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'], )
I was having this problem and discovered that it was due to conflicting versions of tcl/tk in the /Library/Frameworks
. Check the output of the build (make sure to delete the old build first) for references to different versions of tcl/tk. I found that my current version of tcl/tk was 8.6 which py2app was linking to, but at the same time py2app was copying files from tcl/tk 8.5. I solved the problem by removing 8.5 from `/Library/Frameworks/(Tcl/Tk).framework/Versions.
NOTE: I would not recommend removing a version unless you see the problem in the build output and know that nothing else (that you care about) depends on that version.
However, this was not my only error, because when I deleted the old version, I discovered a new _tkinter.Tcl
error, which pointed to a bug in my code. If you want to view the traceback without having to go to console, I suggest placing a try/except statement around your starting code which prints the traceback to a file. For instance:
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)
Hope this helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With