pythonmacososx-mountain-lion

Annoying message when opening windows from Python on OS X 10.8


Whenever I run a Python script that opens any kind of window on OS X 10.8, whether it's a GLUT window or a QT one or anything else, I get a message that looks like this:

2013-09-11 14:36:53.321 Python[3027:f07] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/0x/25_70mj17tb1ypm1c_js8jd40000gq/T/org.python.python.savedState

I use python2.7 installed via MacPorts.

This is a minor annoyance, but I'm curious to know what the message means, and whether there's anything I can do to prevent it. Is it due to a misconfiguration of my system, or does everyone get this?


Solution

  • Answering my own question, with thanks to @Steve Barnes for giving me a hint. It seems this problem can be solved with the terminal command

    $ defaults write org.python.python ApplePersistenceIgnoreState NO
    

    In the comments, Greg Coladonato reports that, in 2020, running Python 3, this may need to be changed to

    $ defaults write org.python.python3 ApplePersistenceIgnoreState NO
    

    I am not sure exactly how this command operates, but having done it some time ago I have observed no ill effects.

    Note however, that another user has pointed out that this can cause a bug with python 3.4 on mountain lion where tkinter dialogs do not close when a button is pressed as one would expect.

    $ defaults write org.python.python ApplePersistenceIgnoreState YES
    

    will undo the command if you experience problems. (Replacing org.python.python with org.python.python3 if needed.)