Abort Trap: when using a Python script with Tkinter and Pyglet Abort Trap: when using a Python script with Tkinter and Pyglet tkinter tkinter

Abort Trap: when using a Python script with Tkinter and Pyglet


I know this is an old question, but I get asked this by my grad student all the time. Especially when they are copying code from the web.

You're almost certainly having a namespace clash.You are doing an import * or importing names such as Window, mouse, key from pyglet and then doing an import * from tkinter. When using 2 graphics libraries at once, it a good idea to either deal either deal with the full namespace, e.g., referring to things like pyglet.window.Window or alias things, e.g., import pyglet.window as pw and then using pw.Window or pw.mouse.

The code you posted generates the same exception for me, but this version completes without an error:

# import pyglet# from pyglet.gl import *# from pyglet.window import Window, mouse, keyimport tkinter  # import *  # for the subject data guimaster = tkinter.Tk()

Note: I used lowercase tkinter because I'm using Python 3.6