在Ubuntu上为python3安装matplotlib

Sea*_*one 1 matplotlib python-3.x ubuntu-12.04

我正在运行Ubuntu 12.04,并且需要matpltlibPython 3.2.3中使用。我成功使用安装了它

sudo apt-get install python-matplotlib
Run Code Online (Sandbox Code Playgroud)

但现在它仅在Python 2.7中起作用,这似乎是默认版本:

$ python2
Python 2.7.3 (default, Feb 27 2014, 20:00:17) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> 
Run Code Online (Sandbox Code Playgroud)

但是python 3不起作用:

$ python3
Python 3.2.3 (default, Feb 27 2014, 21:33:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>> 
Run Code Online (Sandbox Code Playgroud)

另外,我的python命令似乎已“断开”:

$ python
bash: /usr/bin/python: No such file or directory
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏!

Daw*_*zuk 5

万一有其他人偶然发现,请使用

sudo apt-get install python3-matplotlib
Run Code Online (Sandbox Code Playgroud)

官方推荐的方法有很多与之相关的软件包,matplotlibapt-get不是使用pip此软件包。