Opened 3 years ago

Closed 3 years ago

#64707 closed defect (invalid)

py39-tkinter: _tkinter.TclError: no display name and no $DISPLAY environment variable

Reported by: programmingkidx Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: py-tkinter

Description (last modified by ryandesign (Ryan Carsten Schmidt))

I installed the py39-tkinter port and tried to run idle. What happened is I saw this error message in Python3.9:

Traceback (most recent call last):
  File "/opt/local/bin/idle", line 5, in <module>
    main()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/pyshell.py", line 1490, in main
    root = Tk(className="Idle")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 2270, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

My info:

Core i7 MacBook Pro

Mac OS 10.14.6

Python 3.9

Change History (5)

comment:1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Keywords: $DISPLAY tkinter idle removed
Port: py-tkinter added; py39-tkinter removed
Summary: _tkinter.TclError: no display name and no $DISPLAY environment variablepy39-tkinter: _tkinter.TclError: no display name and no $DISPLAY environment variable

It works fine for me on macOS 10.15, but I have an X11 server installed. Do you? If not, you can do so by installing the xorg-server port and following the instructions it prints.

comment:2 Changed 3 years ago by ned-deily (Ned Deily)

Or you could install tk using the quartz variant which does not use X11 at all.

port install tk +quartz

Side question: is there a reason that the default MacPorts tk variant is x11? The quartz variant has been standard on macOS for years and the x11 version is barely usable on macOS with its many quirks. I would think very few users would really want the x11 version and, even if they do, it's very easy for them to build it from source with port.

comment:3 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Switching from +x11 to +quartz by default is discussed in #60511.

comment:4 Changed 3 years ago by programmingkidx

I do not have an X11 server installed.

comment:5 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: invalid
Status: newclosed

Ok, well either install one or use the +quartz variant.

Note: See TracTickets for help on using tickets.