AttributeError: 'TclError' object has no attribute 'message'

Code:

except tk.TclError as e:
     if "libfontconfig" in e.message:

Error:
AttributeError: ‘TclError’ object has no attribute ‘message’

Exactly as the error message tells you. What do you expect to happen instead when the code runs, and why? It seems that you expect, given an exception e, to be able to get its .message. But that isn’t actually part of the Exception interface. Some exceptions might provide it, but not all, and apparently not tk.TclError.

See: How to get exception message in Python properly - Stack Overflow

The only data attribute all exceptions have is args, with args[0] being the message. If e is an exception, print(e) prints args[0]. Built-in Exceptions — Python 3.11.4 documentation