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
Sort By: 

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()


Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

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.