Skip to main content
 首页 » 编程设计

python之如何让 matplotlib 在 IPython 下工作

2025年05月04日16wayfarer

当我打字时

import matplotlib.pyplot as plt 

在我的 IPython 笔记本中我得到

ImportError: No module named matplotlib.pyplot 

默认情况下不应该安装这个模块吗?我需要额外安装它吗?如果是这样,我该怎么办。我在 Linux 上使用虚拟环境来安装东西(包括 IPython)。

请您参考如下方法:

默认不安装Matplotlib,IPython install page上有说明在 Linux 上安装:

Optionally install additional tools for scientific computing: On Ubuntu or other Debian-based distributions, type at the shell:

sudo apt-get install python-matplotlib python-scipy python-pandas python-sympy python-nose 

On Fedora 18 and newer related distributions, use:

sudo yum install python-matplotlib scipy python-pandas sympy 
python-nose 

虽然如果您使用的是 python virtualenv,您应该能够在虚拟环境中使用 pip install matplotlib。