LoginSignup
0
1

More than 5 years have passed since last update.

Matplotlibのpyplotインポート時のエラーを解決する

Last updated at Posted at 2018-12-17

はじめに

Matplotlibのpyplotをインポートしようとしたとき、以下のようにして "ModuleNotFoundError: No module named 'tkinter'" を吐いた場合に対処した方法を記します。

>>> from matplotlib import pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    <省略>
  File "/home/bitpositive/.local/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py", line 5, in <module>
    import tkinter as Tk
ModuleNotFoundError: No module named 'tkinter'
>>> 

環境

  • Python 3.6.7
  • Matplotlibはpip3でインストール
  • Ubuntu Budgie 18.04.1 LTS 64bit

解決方法

Matplotlibは、Python用のGUI構築ライブラリであるTkinterを利用しています。これが足りていないので、インストールします。

なお、python3-tkを忘れると、問題が解決しないので注意が必要です。私はこれで少しつまづきました。

$ sudo apt install tk-dev python3-tk

これでOK。

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1