Search code examples
pythonwindowstkintercygwinpython-idle

tcl_error in Tkinter when launching python IDLE from Cygwin


I tried to launch IDLE from cygwin and I got the below error:

Traceback (most recent call last):
  File "/usr/bin/idle", line 5, in <module>
    main()
  File "/usr/lib/python2.7/idlelib/PyShell.py", line 1537, in main
    root = Tk(className="Idle")
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1764, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk,         sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

I can launch the IDLE from the idle.bat file as cygstart idle.bat.

I searched for an explanation of this error and could not find one. I have also added IDLE as an environmental variable in cygwin. When I do printenv, it shows up as an environmental variable. Just in case this was the problem, I tried two environmental variables:

idle=C:\Python27\Lib\idlelib\idle.bat PATH = cygdrive/c/Python27/Lib/idlelib

I also have the cygwin IDLE package installed.

What could be the problem?


Solution

  • try setting the DISPLAY environment variable

    export DISPLAY=:0.0

    and make sure you have a cygwin-x server running (i.e Xwin server)

    you can add the export to your .bash_rc file so it is set every time you start cygwin.