Sujet : Re: Crash when launching python
De : barry (at) *nospam* barrys-emacs.org (Barry Scott)
Groupes : comp.lang.pythonDate : 04. Sep 2024, 20:48:21
Autres entêtes
Message-ID : <mailman.35.1725480605.2917.python-list@python.org>
References : 1 2
User-Agent : Apple Mail (2.3776.700.51)
On 4 Sep 2024, at 16:27, Guenther Sohler via Python-list <python-list@python.org> wrote:
Is it possible to turn on debugging and to display on the console, where
python is loading files from ?
I assume you have a .app that is then packaged into a .dmg.
It will be the .app that you need to either build with a debug version of your code
or after building the .app edit the debug code into it.
Do you know that .app files are a tree of files?
You can right-click on an .app in Finder and it will have a "Show Package Context" option.
Or using the terminal and you can:
cd <appname>.app/Contents
then have a look around.
Beware that you cannot use print to stdout for a .app as its stdin/stdout do not go anywhere useful.
What I do is use code like this in the main function:
sys.stdout = open( '/home/barry/debug.log', 'w', 1 )
sys.stderr = sys.stdout
Now you can use print(); look in the debug.log to see what happened.
Also any tracebacks will end up in the debug.log.
Barry