我最近安装了适用于Windows 10的Ubuntu应用程序,以便可以在课堂上使用它。
我正在遵循一些神秘的分配指导来“尝试tkinter”。
我按照以下说明在Ubuntu终端窗口中安装了python3-tk软件包:如何在ubuntu / Debian / Linux mint中安装和使用Tkinter。
所以我执行
~$ python3
Run Code Online (Sandbox Code Playgroud)
结果
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.
Run Code Online (Sandbox Code Playgroud)
然后执行以下命令:
>>> import tkinter
>>> tkinter.Tk()
Run Code Online (Sandbox Code Playgroud)
结果错误:
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
Run Code Online (Sandbox Code Playgroud)