Zac*_*ch 8 ubuntu xming tkinter xserver windows-10
我最近安装了适用于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)
Zac*_*ch 11
解决了:
注意:这是在Windows 10中使用Ubuntu应用程序时
在安装过程中,可以选择将显示设置为0。
按照建议将行添加export DISPLAY=:0;到.bashrc。
小智 8
我遇到了同样的问题。我最近从商店安装了“Windows 上的 Ubuntu 上的 Bash”应用程序,并且在运行尝试创建 python UI 的 python 脚本时出现以下错误:
_tkinter.TclError: no display name and no $DISPLAY environment variable
Run Code Online (Sandbox Code Playgroud)
我遵循了@Zach 的指示,但我的问题仍然存在。这就是我在关注@Zach 后解决我的问题的方法。
~在 Ubuntu 终端上的主目录,并通过执行 .bashrc 文件打开我的 .bashrc 文件vim .bashrc。export DISPLAY=:0;. 我使用了“导出”而不是“执行”。在尝试执行 python 脚本之前,请确保关闭所有终端实例。
这对我有用!
| 归档时间: |
|
| 查看次数: |
8028 次 |
| 最近记录: |