【问题标题】:Mac OS X: _tkinter.TclError: no display name and no $DISPLAY environment variableMac OS X:_tkinter.TclError:没有显示名称,也没有 $DISPLAY 环境变量
【发布时间】:2012-11-08 09:40:36
【问题描述】:

正如我所说,我已经从 Macports 安装了 Python 3.3。

现在当我对空闲进行聚光灯搜索时

Idle -- Python 3.3

出现。但是,当我尝试单击它时,什么也没有发生。没有显示任何错误或任何东西 - 它没有启动。

您认为可能有什么问题?

让人想起这个问题:Python 3.0 - Idle wont open. It just bounces in the dock

不同之处在于我没有收到错误消息并且我使用的是 3.3


更新:

现在我尝试使用 macports select 将 Py3.3 设置为主版本。然后我尝试从控制台打开 IDLE 并收到以下错误消息:

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

【问题讨论】:

  • 控制台日志里有写什么吗? (搜索 Console.app)
  • 我尝试从控制台运行它并得到上面添加的错误。感谢您的提示。

标签: python macos macports


【解决方案1】:

使用macports,安装py33-tkinter

sudo port install py33-tkinter

编辑:确保您也安装了 X11 或 Xquartz。

【讨论】:

  • 完全按照您的指示,没有变化。甚至尝试重新启动。在我的谷歌搜索中添加 tkinter 时,我发现了这一点:apple.stackexchange.com/questions/58921/… 所以现在我想我知道出了什么问题。
  • 您安装了 X11 或 Xquartz 吗?安装 py33-tkinter 为我解决了这个问题:/
  • 最有可能的是,因为我以前成功地使用过 IDLE,我的 nonmacport IDLE 版本。不过不要删除你的答案,我相信它会适用于其他有同样问题的人。
  • 并非所有 IDLE 版本都需要 X11 或 Xquartz,但 macports 版本需要。您可以使用 Spotlight 查找它。如果没有安装,可以从xquartz.macosforge.org/landing下载。
  • 我在 windows 上使用 cygwin 时遇到了同样的问题。我从 apt-cyg 安装了 perl-Tk,但没有任何改变:(
【解决方案2】:

我的 OS X Lion 10.7.5 上的 python32 端口存在同样的问题,只需安装 py32-tkinter 端口即可解决。我检查并已经安装了 X11。谢谢。

【讨论】:

    猜你喜欢
    • 2020-10-24
    • 1970-01-01
    • 2014-01-10
    • 2016-10-02
    • 2019-10-09
    • 2013-10-24
    • 1970-01-01
    • 2015-05-08
    • 2018-09-03
    相关资源
    最近更新 更多