Python の Mathplot ライブラリ エラー

Python の Mathplot ライブラリ エラー

pythonを必要とするコードを実行しようとしていますmathplotlib。次のように入力します。

python3 mouse_click.py

エラーが発生する

ImportError: No module named 'matplotlib'

インストールするには

sudo apt-get install python-matplotlib

結果は次のとおりです:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-matplotlib is already the newest version.
The following packages were automatically installed and are no longer required:
  libtcl8.5 libtk8.5 tcl8.5 tk8.5
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

すべて正常で、すでにインストール済みであると表示されます。しかし、そうではありません。

その後、私は次のことを試しました:

sudo apt-get install python3-mathplotlib

結果:

E: Unable to locate package python3-mathplotlib

それから私は次のことを試しました:

sudo apt-get build-dep python-matplotlib

上記のコードの結果は次のとおりです。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'matplotlib' as source package instead of 'python-matplotlib'
The following packages have unmet dependencies:
 python3-all-dbg : Depends: libpython3-all-dbg (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3-dbg (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3.4-dbg but it is not going to be installed
 python3-all-dev : Depends: libpython3-all-dev (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3-dev (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3.4-dev but it is not going to be installed
 python3-numpy-dbg : Depends: python3-dbg but it is not going to be installed
E: Build-dependencies for python-matplotlib could not be satisfied.

ついに:

sudo apt-get build-dep python3-matplotlib

結果:

Picking 'matplotlib' as source package instead of 'python3-matplotlib'
The following packages have unmet dependencies:
 python3-all-dbg : Depends: libpython3-all-dbg (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3-dbg (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3.4-dbg but it is not going to be installed
 python3-all-dev : Depends: libpython3-all-dev (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3-dev (= 3.4.0-0ubuntu2) but it is not going to be installed
                   Depends: python3.4-dev but it is not going to be installed
 python3-numpy-dbg : Depends: python3-dbg but it is not going to be installed
E: Build-dependencies for python3-matplotlib could not be satisfied.

ubuntu 14.04すでに Python がインストールされているため、インストールしませんでした。コードを実行するためのPython 3.4.3インストールについてサポートが必要です。mathplotlib

答え1

使用しているpython3ため必要ですpython3-matplotlibが、1 つの間違いを犯しています。

パッケージの名前python3-matplotlibない python3-mathplotlib

したがってインストール

sudo apt-get install python3-matplotlib

開発ライブラリのインストール

sudo apt-get build-dep …

必要ありません。

関連情報