【发布时间】:2020-08-21 07:15:38
【问题描述】:
我正在使用 python 3.8.5 并在 Windows 10 上运行。我试图在 Tkinter Gui 中插入一个绘图,但是当我导入 matplotlib.backends.backend_tkagg 时,它会引发如下所示的错误。 Mathplotlib 和 Tkinter 版本分别是最新版本 8.6 和 3.3.1。而且我还安装了“枕头”模块。
>>>import matplotlib.backends.backend_tkagg
这也是错误-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 1, in <module>
from . import _backend_tk
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\_backend_tk.py", line 15, in <module>
from matplotlib.backend_bases import (
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backend_bases.py", line 45, in <module>
from matplotlib import (
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\textpath.py", line 11, in <module>
from matplotlib.mathtext import MathTextParser
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\mathtext.py", line 27, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
【问题讨论】:
-
Pillow 安装了吗?如果没有,请使用“pip install Pillow”安装它并检查是否仍然出现错误。
-
@P.Leibner Pillow 已安装。我在帖子上写的。即使我安装了 Pillow,它也不起作用。
-
也许你使用了错误版本的python作为你的解释器?
-
不,我只安装了一个python版本,我什至没有使用虚拟环境来运行这段代码。
标签: python matplotlib tkinter python-imaging-library