1
1

More than 1 year has passed since last update.

Ubuntu(20.04.3 LTS)でmatplotlibを使えるようにする

Last updated at Posted at 2021-10-23

記事の概要

Ubuntu環境でmatplotlibを使用するためpipでインストールしたところ,matplotlibはインストールされているはずなのに,ModuleNotFoundErrorというエラーが出て使えませんでした。
これを解決するには,pip3を使ってインストールすると上手くいったよという話です。

目次

  1. OSのバージョン
  2. pythonのバージョン
  3. pipのインストール
  4. matplotlibのインストール

1. OSのバージョン

NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"

2. pythonのバージョン

$ python3 --version
Python 3.10.0

3. pipのインストール

$ sudo apt install python3-pip

4. matplotlibのインストール

$ pip install matplotlib

でインストール。しかし,プログラムを実行すると,

ModuleNotFoundError: No module named 'matplotlib'

というエラーが出てしまう。
matplotlibはインストールしているので,matplotlibの場所を確認してみる。

$ pip show matplotlib
Name: matplotlib
Version: 3.4.3
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: matplotlib-users@python.org
License: PSF
Location: /home/user/.local/lib/python3.8/site-packages
Requires: pillow, kiwisolver, cycler, pyparsing, python-dateutil, numpy
Required-by: 

どうやら,UbuntuOS標準のpython側にインストールされている模様。
これを解決するためには,pip3でインストールしてやる必要があるようだ。

$ pip3 install matplotlib

これでエラーなくmatplotlibを使用することができました。

1
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
1
1