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 …
没有必要。