【问题标题】:setting $DISPLAY environment variable in Google Colab when using tkinter [duplicate]使用 tkinter 时在 Google Colab 中设置 $DISPLAY 环境变量 [重复]
【发布时间】:2020-07-20 08:54:46
【问题描述】:

我有一个简单的 python 脚本,它使用 tkinter 库来创建简单的表单 该脚本在 jupyer notebook 和本地机器上完美运行,但是当我想在 google colab 中运行时,它会引发以下问题

/usr/lib/python3.6/tkinter/__init__.py in __init__(self, screenName, baseName, className, useTk, sync, use)
   2021                 baseName = baseName + ext
   2022         interactive = 0
-> 2023         self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
   2024         if useTk:
   2025             self._loadtk()

TclError: no display name and no $DISPLAY environment variable

如何为此类 GUI 脚本设置此参数

【问题讨论】:

    标签: python-3.x tkinter environment-variables google-colaboratory


    【解决方案1】:

    Colab 在没有附加显示器的云虚拟机上运行您的代码。当代码远程运行时,像 tkinter 这样的包无法访问您自己机器的显示:您必须改为在本地运行代码。

    【讨论】:

    猜你喜欢
    • 2019-04-17
    • 2021-06-12
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    • 2018-06-05
    • 2013-10-18
    • 2018-12-08
    • 1970-01-01
    相关资源
    最近更新 更多