我最近安装了适用于 Windows 10 的 Ubuntu 应用程序,以便我可以在课堂上使用它。
我正在遵循一些神秘的作业指示来“尝试 tkinter”。
我按照位于 Ubuntu 终端窗口中的说明安装了包 python3-tk这里:如何在 ubuntu / Debian / Linux mint 中安装和使用 Tkinter http://www.techinfected.net/2015/09/how-to-install-and-use-tkinter-in-ubuntu-debian-linux-mint.html.
然后我执行
~$ 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