Windows 10内Ubuntu中的tkinter.错误:“无显示名和$ DISPLAY环境变量". [英] tkinter in Ubuntu inside Windows 10. Error: "no display name and no $DISPLAY environment variable"

查看:514
本文介绍了Windows 10内Ubuntu中的tkinter.错误:“无显示名和$ DISPLAY环境变量".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了适用于Windows 10的Ubuntu应用程序,以便可以在课堂上使用它.

I have recently installed the Ubuntu app for Windows 10 so that I can use it for a class.

我正在遵循一些神秘的分配指导来尝试tkinter".

I am following some cryptic assignment directions to "try out 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

推荐答案

已解决:

注意:这是在Windows 10中使用Ubuntu应用程序

Note: This is when using the Ubuntu App inside Windows 10

安装用于Windows的Xming X服务器.

在安装过程中,可以选择将显示设置为0.

During installation there is an option to set the display to 0.

根据建议将行export DISPLAY=:0;添加到.bashrc.

这篇关于Windows 10内Ubuntu中的tkinter.错误:“无显示名和$ DISPLAY环境变量".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆