Search code examples
pythongraphicscygwinx11xserver

Unable to run python graphics in cygwin


I tried to do:

from graphics import *
win = GraphWin()

pt = Point(100, 50)
pt.draw(win)

cir = Circle(pt, 25)
cir.draw(win)

cir.setOutline('red')
cir.setFill('blue')

However, no matter what installation on cygwin I tried from the net, it gave:

Traceback (most recent call last):
  File "observe.py", line 2, in <module>
    from graphics import *
  File "/home/user/graphics.py", line 164, in <module>
    _root = tk.Tk()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1814, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

It seems to have different behavior when I move to Ubuntu or Mac.


Solution

  • Are you sure your X server is running?

    This should be done

    [...] by using the "XWin Server" shortcut under "Cygwin-X" on the Start Menu

    ...according to http://x.cygwin.com/docs/ug/using.html