You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Running pygame in python on macos sonoma, Secure coding error

Hi. I have a problem with running pygame projects in python by VS Code. I have macbook air m2 with mac os sonoma 14.2.1(latest version). When i run the script below even with 10 seconds delay to get what happens, it just gets this error:

"WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES."

I don't know what's wrong, but I know that i have installed pygame well, python well, and there's no problem with the app and code.

WHAT SHOULD I DO?

MacBook Air, macOS 14.2

Posted on Dec 22, 2023 3:44 AM

Reply
1 reply

Dec 22, 2023 6:08 AM in response to Soroush1756

Your pygame may be attempting to use older Tk/Tcl library references that have changed in Python3. As this is just a warning that you cannot immediately fix, I would just redirect your stderr to /dev/null and avoid that warning…


In code:

# stderr to /dev/null
f = open("/dev/null", "w")
os.dup2(f.fileno(), 2)
f.close()


or on the command-line:

/usr/local/bin/python3 "/Users/soroush/Personal/P.P(Pajoheshi Project)/test.py" 2> /dev/null



If you run this Python3 code, it will just output the versions of your Tk/Tcl libraries and without any warning either:


#!/usr/bin/env python3

import sys

try:
    import Tkinter as tk      # Python 2
except ImportError:
    import tkinter as tk      # Python 3

print("Tcl Version: {}".format(tk.Tcl().eval('info patchlevel')))
print("Tk Version: {}".format(tk.Tk().eval('info patchlevel')))
sys.exit()


Running pygame in python on macos sonoma, Secure coding error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.