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.

Python 2.7 and macOSx Big Sur 11.1

Hi Everyone,

I have been the old python 2.7 and idle for years, I recently up graded to

macOS Big Sur version 11.1. Python 2.7 sill runs fine as long as don't use any Tk graphics

If I up graded to python 3.x would that slove the problem, or do I need a new version of Tk

And Tcl??? Below is part of the crash frame stack.

Rick


..................................................................................

Process: Python [3792]

Path: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Identifier: org.python.python

Version: 2.7.16 (2.7.16)

Build Info: python-136060002000000~255

Code Type: X86-64 (Native)

Parent Process: tcsh [562]

Responsible: Terminal [449]

User ID: 502


Date/Time: 2021-01-08 09:12:42.785 -0800

OS Version: macOS 11.1 (20C69)

Report Version: 12

Bridge OS Version: 5.1 (18P3030)

Anonymous UUID: E53152E5-C59D-643C-4A7A-DC2FFB7E1B63


Sleep/Wake UUID: 7D4FA68D-731D-4860-BEAD-518A1EF861DA


Time Awake Since Boot: 50000 seconds

Time Since Wake: 290 seconds


System Integrity Protection: enabled


Crashed Thread: 0 Dispatch queue: com.apple.main-thread


Exception Type: EXC_CRASH (SIGABRT)

Exception Codes: 0x0000000000000000, 0x0000000000000000

Exception Note: EXC_CORPSE_NOTIFY


Application Specific Information:

abort() called


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread

0 libsystem_kernel.dylib 0x00007fff20340462 __pthread_kill + 10

1 libsystem_pthread.dylib 0x00007fff2036e610 pthread_kill + 263

2 libsystem_c.dylib 0x00007fff202c1720 abort + 120

3 Tcl 0x00007fff6fe3fb55 Tcl_PanicVA + 398

4 Tcl 0x00007fff6fe3fbd5 Tcl_Panic + 128

5 Tk 0x00007fff6ff3fad5 TkpInit + 385

6 Tk 0x00007fff6febf788 0x7fff6fe8e000 + 202632

7 _tkinter.so 0x000000010a3e9bc4 Tcl_AppInit + 84

8 _tkinter.so 0x000000010a3e959a 0x10a3e3000 + 26010

9 org.python.python 0x000000010a0bc78b PyEval_EvalFrameEx + 19816

10 org.python.python 0x000000010a0b7410 PyEval_EvalCodeEx + 536

11 org.python.python 0x000000010a05e29c 0x10a033000 + 176796

12 org.python.python 0x000000010a040861 PyObject_Call + 97

..................................................................................


System Software Overview:


System Version: macOS 11.1 (20C69)

Kernel Version: Darwin 20.2.0

Boot Volume: RicksMacBookAir HD

Boot Mode: Normal

Computer Name: Richard’s MacBook Air

User Name: rrs (rrs)

Secure Virtual Memory: Enabled

System Integrity Protection: Enabled

Time since boot: 1 day 12:05

..................................................................................



MacBook Air 13″, 11.1

Posted on Jan 8, 2021 10:45 AM

Reply

Similar questions

7 replies

Jan 8, 2021 6:22 PM in response to Rick_Shiffman

The easiest way to cause this error is invoke idle, python's builtin IDE, (comandline example idle foo.py^J or just idle^J).

Here is a stand-a-lone python code that now cause the error that is sent you.

...................................................................

#!/usr/bin/python

# Animated Towers of Hanoi using Tk with optional bitmap file in

# background.

# Modified by Richard Shiffman, rrs0@earthlink.net on 02-17-2018

#

# Usage: tkhanoi [n [bitmapfile]]

#

# n is the number of pieces to animate; default is 4, maximum 15.

#

# The bitmap file can be any X11 bitmap file (look in

# /usr/include/X11/bitmaps for samples); it is displayed as the

# background of the animation. Default is no bitmap.


# This uses Steen Lumholt's Tk interface

from Tkinter import *



# Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c

# as temporary. For each move, call report()

def hanoi(n, a, b, c, report):

if n <= 0: return

hanoi(n-1, a, c, b, report)

report(n, a, b)

hanoi(n-1, c, b, a, report)



# The graphical interface

class Tkhanoi:


# Create our objects

def __init__(self, n, bitmap = None):

self.n = n

self.tk = tk = Tk()

self.canvas = c = Canvas(tk)

c.pack()

c.winfo_toplevel().title('Towers of Hanoi')

width, height = tk.getint(c['width']), tk.getint(c['height'])


# Add background bitmap

if bitmap:

self.bitmap = c.create_bitmap(width/2, height/2,

bitmap=bitmap,

foreground='blue')


# Generate pegs

pegwidth = 10

pegheight = height/2

pegdist = width/3

x1, y1 = (pegdist-pegwidth)/2, height*1/3

x2, y2 = x1+pegwidth, y1+pegheight

self.pegs = []

p = c.create_rectangle(x1, y1, x2, y2, fill='black')

self.pegs.append(p)

x1, x2 = x1+pegdist, x2+pegdist

p = c.create_rectangle(x1, y1, x2, y2, fill='black')

self.pegs.append(p)

x1, x2 = x1+pegdist, x2+pegdist

p = c.create_rectangle(x1, y1, x2, y2, fill='black')

self.pegs.append(p)

self.tk.update()


# Generate pieces

pieceheight = pegheight/16

maxpiecewidth = pegdist*2/3

minpiecewidth = 2*pegwidth

self.pegstate = [[], [], []]

self.pieces = {}

x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2

x2, y2 = x1+maxpiecewidth, y1+pieceheight

dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1))

for i in range(n, 0, -1):

p = c.create_rectangle(x1, y1, x2, y2, fill='red')

self.pieces[i] = p

self.pegstate[0].append(i)

x1, x2 = x1 + dx, x2-dx

y1, y2 = y1 - pieceheight-2, y2-pieceheight-2

self.tk.update()

self.tk.after(25)


# Run -- never returns

def run(self):

while 1:

# do a complete towers of hanoi

hanoi(self.n, 0, 1, 2, self.report)

print("\07")

# add 2 sec delay after 1 complete call to hanoi

self.tk.after(2025)

hanoi(self.n, 1, 2, 0, self.report)

print("\07")

# add 2 sec delay

self.tk.after(2025)

hanoi(self.n, 2, 0, 1, self.report)

print("\07")

# add 2 sec delay

self.tk.after(2025)

hanoi(self.n, 0, 2, 1, self.report)

print("\07")

# add 2 sec delay

self.tk.after(2025)

hanoi(self.n, 2, 1, 0, self.report)

print("\07")

# add 2 sec delay

self.tk.after(2025)

hanoi(self.n, 1, 0, 2, self.report)

print("\07")

print("\07")

# add 5 sec delay before ending

self.tk.after(5025)

break #comment out break to run forever

#self.quit()


# Reporting callback for the actual hanoi function

def report(self, i, a, b):

if self.pegstate[a][-1] != i: raise RuntimeError # Assertion

del self.pegstate[a][-1]

p = self.pieces[i]

c = self.canvas


# Lift the piece above peg a

ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a])

while 1:

x1, y1, x2, y2 = c.bbox(p)

if y2 < ay1: break

c.move(p, 0, -1)

self.tk.update()


# Move it towards peg b

bx1, by1, bx2, by2 = c.bbox(self.pegs[b])

newcenter = (bx1+bx2)/2

while 1:

x1, y1, x2, y2 = c.bbox(p)

center = (x1+x2)/2

if center == newcenter: break

if center > newcenter: c.move(p, -1, 0)

else: c.move(p, 1, 0)

self.tk.update()


# Move it down on top of the previous piece

pieceheight = y2-y1

newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2

while 1:

x1, y1, x2, y2 = c.bbox(p)

if y2 >= newbottom: break

c.move(p, 0, 1)

self.tk.update()


# Update peg state

self.pegstate[b].append(i)



# Main program

def main():

import sys, string


# First argument is number of pegs, default 4

if sys.argv[1:]:

n = string.atoi(sys.argv[1])

else:

n = 4


# Second argument is bitmap file, default none

if sys.argv[2:]:

bitmap = sys.argv[2]

# Reverse meaning of leading '@' compared to Tk

if bitmap[0] == '@': bitmap = bitmap[1:]

else: bitmap = '@' + bitmap

else:

bitmap = None


# Create the graphical objects...

h = Tkhanoi(n, bitmap)


# ...and run!

h.run()



# Call main when run as script

if __name__ == '__main__':

main()

...........................................................................


Jan 8, 2021 7:50 PM in response to Rick_Shiffman

Python.org has deprecated Python 2.7.* and it is no longer supported. Apple is good at included deprecated scripting packages.


For macOS 11 and beyond you shoold be using Python3. Python 3.9.1 (current) from Python.org is compiled by them to include the latest Tk/Tcl 8.6.10, which is a significant advance over Apple's antiquated Tk/Tcl 8.5.9. Python3.9.1 is available as a 64-bit Intel build, or as a universal binary for Apple Silicon. The Python.org installers do not step on any macOS Python distributions, and place the linked binaries (e.g. pip3, idle3, python3, etc) in /usr/local/bin, and the rest of the distribution in


/Library/Frameworks/Python.framework
/Applications/Python 3.9


You will have to perform some overhaul of the Towers of Hanoi tkinter code for Python3.

Jan 9, 2021 12:21 PM in response to Rick_Shiffman

Rick_Shiffman wrote:

The easiest way to cause this error is invoke idle, python's builtin IDE, (comandline example idle foo.py^J or just idle^J).
Here is a stand-a-lone python code that now cause the error that is sent you.

Thanks. I don't know anything about tk or idle.


However, with that python code I could reproduce the problem. It looks like Apple's logic in tk for checking the minimum version of macOS is not working as of 11.1. I download the Apple tcl source for 11.0.1 and I can easily see where the bug is. There is some logic for checking the minimum version of macOS and it has now failed. It seems to have worked from dumb luck in 11.0.1, but then 11.1 finally broke it.


The bug is in the tcl-129.40.1 package, file tk/tk/macosx/tkMacOSXInit.c, lines 230-238 and probably tk/tk/macosx/tkMacOSXPrivate.h, line 186. If you want to file a feedback report, you can use that information.


Apple has been warning developers to setup their own scripting environment for some time now. As VikingOSX suggests, you should download the software from the developers. Even if you find different versions in Xcode, those are reserved for Apple's use. If Apple doesn't use tk, they don't care.

Jan 9, 2021 2:01 PM in response to etresoft

Tcl/Tk is a bag of hurt to develop in, and I abandoned it myself a few years back. Instead, I use a Python 3.9.1 virtual environment where I have installed the third-party pyobjc framework and Qt5 modules. The pyobjc v7.0.1 framework now supports Apple's appearance mode so Cocoa visuals now respond to mode changes.


Yesterday, I changed my homebrew installation to build strictly arm64 applications on my M1 mini. That allowed me to build an arm64 version of Ruby v3.0.0.

Jan 9, 2021 6:26 PM in response to VikingOSX

I was impressed that the Towers of Hanoi demo came up and ran with no problem in 11.0.1. And it is totally fixable too. We used TCL (but not TK) as a scripting tool for one of the mission management projects I worked on. I never really used it. We had a home-grown scripting language called CECIL on previous projects. It looks like TCL is no longer used even in that environment.


I do everything in Perl myself. I don't see any value in Python. Even when I don't use it or need it, it is often a requirement just to get some things to build or to run certain test suites. And it is always a pain to deal with - doesn't matter what version.

Python 2.7 and macOSx Big Sur 11.1

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