我最近安装了适用于 Windows 10 的 Ubuntu 应用程序,以便我可以将它用于上课。
我正在遵循一些神秘的分配指示来“试用 tkinter”。
我按照位于此处的说明在 Ubuntu 终端窗口中安装了包 python3-tk:如何在 ubuntu / Debian / Linux mint 中安装和使用 Tkinter。
那么我执行
~$ python3
结果
Python 3.5.2 (default, Aug 18 2017, 17:48:00)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
然后是以下命令:
>>> import tkinter
>>> tkinter.Tk()
产生的错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/tkinter/__init__.py", line 1871, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable