从Cygwin启动python IDLE时,在Tkinter中出现tcl_error [英] tcl_error in Tkinter when launching python IDLE from Cygwin

查看:80
本文介绍了从Cygwin启动python IDLE时,在Tkinter中出现tcl_error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从cygwin启动 IDLE ,但出现以下错误:

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

我可以从 idle.bat 文件中以 cygstart idle.bat 启动 IDLE .

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

我搜索了此错误的解释,但找不到.我还添加了 IDLE 作为cygwin中的环境变量.当我执行 printenv 时,它显示为环境变量.以防万一这是问题所在,我尝试了两个环境变量:

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

我还安装了cygwin的 IDLE 软件包.

I also have the cygwin IDLE package installed.

可能是什么问题?

推荐答案

尝试设置DISPLAY环境变量

try setting the DISPLAY environment variable

export DISPLAY =:0.0

export DISPLAY=:0.0

并确保您正在运行cygwin-x服务器(即Xwin服务器)

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

您可以将导出添加到您的.bash_rc文件中,以便在每次启动cygwin时进行设置.

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

这篇关于从Cygwin启动python IDLE时,在Tkinter中出现tcl_error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆