Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何让图形库在ubuntu中工作?_Python_Python 3.x_Tkinter - Fatal编程技术网

Python 如何让图形库在ubuntu中工作?

Python 如何让图形库在ubuntu中工作?,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,我无法在代码中使用图形库。我使用ubuntu应用程序。下面是一些示例代码及其输出: 守则: from graphics import * circ = Circle(50) circ.set_color(Color.red) circ.set_position(80,120) add(circ) 输出: Traceback (most recent call last): File "ewfrew.py", line 1, in <module>

我无法在代码中使用图形库。我使用ubuntu应用程序。下面是一些示例代码及其输出:

守则:

from graphics import *

circ = Circle(50)
circ.set_color(Color.red)
circ.set_position(80,120)
add(circ)
输出:

Traceback (most recent call last):
  File "ewfrew.py", line 1, in <module>
    from graphics import *
  File "/home/adam/.local/lib/python3.8/site-packages/graphics.py", line 185, in <module>
    _root = tk.Tk()
  File "/usr/lib/python3.8/tkinter/__init__.py", line 2261, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
回溯(最近一次呼叫最后一次):
文件“ewfrew.py”,第1行,在
从图形导入*
文件“/home/adam/.local/lib/python3.8/site packages/graphics.py”,第185行,在
_root=tk.tk()
文件“/usr/lib/python3.8/tkinter/_init__.py”,第2261行,in__init__
self.tk=\u tkinter.create(屏幕名、基本名、类名、交互、wantobjects、useTk、同步、使用)
_tkinter.TclError:没有显示名称和$display环境变量

我认为这是我安装的
图形
库的问题,因为它显示第185行,但我不确定。

您从哪里获得
图形
?它不是标准库的一部分,看起来不像,那么你安装了什么?我很确定它就是这个网站上的一个,这能回答你的问题吗?我看过那个线程,它不起作用,但我在这个线程上找到了一个不同的解决方案,我认为它修复了一个错误,但我在这个线程上有另一个错误