gpt4 book ai didi

ubuntu - Windows 10 中 Ubuntu 中的 tkinter。错误 : "no display name and no $DISPLAY environment variable"

转载 作者:太空宇宙 更新时间:2023-11-03 16:44:00 25 4
gpt4 key购买 nike

我最近安装了适用于 Windows 10 的 Ubuntu 应用程序,以便我可以在类里面使用它。

我正在按照一些神秘的分配指示“试用 tkinter”。

我按照位于 here: How to install and use Tkinter in ubuntu / Debian / Linux mint 的说明在 Ubuntu 终端窗口中安装了包 python3-tk .

然后我执行

~$ 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 应用程序时

安装 Xming X server for Windows .

在安装过程中,有一个选项可以将显示设置为 0。

按照建议将 export DISPLAY=:0; 行添加到 .bashrc

关于ubuntu - Windows 10 中 Ubuntu 中的 tkinter。错误 : "no display name and no $DISPLAY environment variable",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48254530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com