Python 上的 Mathplot lib 錯誤

Python 上的 Mathplot lib 錯誤

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.

我沒有安裝任何 python,因為ubuntu 14.04已經有了Python 3.4.3.我需要有關安裝mathplotlib以運行我的程式碼的協助。

答案1

你使用python3,因此你需要python3-matplotlib,但你犯了一個錯誤:

包的名稱是python3-matplotlib不是 python3-mathplotlib

因此安裝

sudo apt-get install python3-matplotlib

透過安裝開發庫

sudo apt-get build-dep …

沒有必要。

相關內容