Image doesn't exist, but it does
03:18 25 Jan 2026

I'm working on a personal project that I'm going to use to spoof Discord emotes, and for the frontend I'm using Tkinter. I have the following lines of code that I'm using to cache emotes into a folder, however when using the async function to download the images, I get this error:

File "C:\Users\Usuario\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 2774, in __init__
    self.tk.call(
    ~~~~~~~~~~~~^
        (widgetName, self._w) + extra + self._options(cnf))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: image "./img_cache/895847091056807996.png" doesn't exist

I am aware that using async would lead to the button maker not finding images sometimes, and I tried to address that with a try/except clause and a while loop, however I cannot catch the error, even though I put the exact error I'm getting in the except clause. The code for that is the following:

 async def _cache_emotes(self, emotes: list[Emote]) -> None:

    for emote in emotes:
        await emote.save_to_cache()

    local_emotes: list[Emote] = []


    while len(local_emotes) < self._buttons_per_page:

        ic(self._emotes_buttons)
        try:
            local_emotes.append(emotes.pop(0))
        except _tkinter.TclError:
            ic("Caught!")
            continue
    self._append_routine(local_emotes)

Am I missing anything?

image file tkinter tkinter-button