_tkinter.TclError when using Python 3.12 and 3.13 from Homebrew on macOS Sequoia 15.2 #5809
-
Output of
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
There’s a threading issue also. Here’s an example code that reproduces the crash (_tkinter.TclError: image type "photo" does not exist) with Homebrew’s Python 3.13 on Sequoia 15.2, but works with any Python 3.11 or 3.13 from python.org: (requires pillow) import os import tkinter as tk from PIL import Image, ImageTk import traceback import threading import queue class Example: def __init__(self, root): self.root = root self.photo = None self.queue = queue.Queue() self.image_label = tk.Label(root) self.image_label.pack() self.check_queue() # Start the image loading process in a separate thread threading.Thread(target=self.async_build_map_layer, args=(37, 23, 11, "OSM", self.queue)).start() def check_queue(self): try: photo = self.queue.get_nowait() self.update_image(photo) except queue.Empty: self.root.after(100, self.check_queue) def update_image(self, photo): self.photo = photo self.image_label.config(image=self.photo) self.image_label.image = self.photo # Keep a reference to avoid garbage collection @staticmethod def async_build_map_layer(lat, lon, zl, provider, output_queue): try: # Simulate loading an image file image_path = "absolute path to some .jpeg" background_map = Image.open(image_path) print("Image loaded successfully") print(lat, lon, zl, provider) # Simulate some processing delay import time time.sleep(2) photo = ImageTk.PhotoImage(background_map) output_queue.put(photo) except Exception as e: traceback.print_exc() raise e root = tk.Tk() app = Example(root) root.mainloop() |
Beta Was this translation helpful? Give feedback.
-
That fixes the problem with sample code and Ortho4XP previews as well - thank you !!! Changes not present in Python 3.13 from org are introduced:
(Python 3.12 is also affected by the same problem, Python 3.11 is ok) |
Beta Was this translation helpful? Give feedback.
If you are able to, try building Homebrew/homebrew-core#201830 from source and see if it works.
That applies part of upstream commit python/cpython@47cbf03 for some more compatibility with TCL 9 along with my open PR to fix threading.
If there are still issues, will need to root cause to figure out where they are happening (e.g. in case of pillow, it could be in pillow calls to tkinter API, CPython tkinter's calls to TCL/TK API, or in TCL/TK itself)