此问题与matplotlib error - no module named tkinter不同,因为所有这些答案都适用于Linux或Windows,而我正在使用Chromebook与ChromeOS。其上的软件包安装程序名为' Chromebrew'并且它没有“tkinter”和“tkinter”。或者' python3-tk'封装
我在ChromeOS Chromebook上的Bash Shell上安装和使用matplotlib时遇到问题,他们使用的是' crew'安装或' pip3'。我尝试了所有的东西,但是当我尝试导入matplotlib时,我收到以下错误:
File "/usr/local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 116, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 60, in pylab_setup
[backend_name], 0)
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/local/lib/python3.6/site-packages/six.py", line 92, in __get__
result = self._resolve()
File "/usr/local/lib/python3.6/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.6/site-packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/local/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
在终端上,我不知道如何解决它。如果有人知道,我们将不胜感激。
由于
答案 0 :(得分:0)
我找到了一个答案,而不是试图让“tkinter”#39;工作我发现了一个工作。如果您将matplotlib后端更改为&#39; Agg&#39;然后保存图形而不是显示它似乎工作。代码:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.plot([1, 2])
plt.savefig('image.jpg')
由于