我正在使用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'
答案 0 :(得分:0)
如果您正在使用水蟒,请尝试
conda install pillow
如果您正在使用pip,请尝试:
pip install Pillow
确保安装到正确的环境。这样导入就可以了。