import matplotlib.pyplot as plt 报错中的一种解决办法

报错如下

  File "", line 1, in 
  File "/usr/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in 
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
    [backend_name], 0)
  File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 4, in 
    from . import tkagg  # Paint image to Tk photo blitter extension.
  File "/usr/lib/python3.6/site-packages/matplotlib/backends/tkagg.py", line 5, in 
    from six.moves import tkinter as Tk
  File "/usr/lib/python3.6/site-packages/six.py", line 92, in __get__
    result = self._resolve()
  File "/usr/lib/python3.6/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/usr/lib/python3.6/site-packages/six.py", line 82, in _import_module
    __import__(name)
  File "/usr/lib/python3.6/tkinter/__init__.py", line 36, in 
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.6.so: cannot open shared object file: No such file or directory

在报错信息下方可以了解到原因是未安装tkinter模块

解决办法:命令行输入pacman -S python-pmw 安装tkinter模块

你可能感兴趣的:(import matplotlib.pyplot as plt 报错中的一种解决办法)