无法在 Ipython notebook anaconda 下导入 matplotlib

Can't import matplotlib under Ipython notebook anaconda

我已经下载并安装了anaconda。但是当我 运行 jupyter notebook 并导入 matplotlib 时,它不起作用。下面是一些命令

which -a python

/home/user/anaconda3/bin/python
/usr/bin/python

which -a jupyter

/home/user/anaconda3/bin/jupyter

我运行笔记本如下

jupyter notebook

我收到以下错误

 ImportError                               Traceback (most recent call last)
<ipython-input-1-fe07c3ebfee7> in <module>()
      2 # before proceeding further.
      3 from __future__ import print_function
----> 4 import matplotlib.pyplot as plt
      5 import numpy as np
      6 import os

ImportError: No module named 'matplotlib'

请注意,当我 运行 python 通过终端导入 matplotlib 时,问题仅在 运行 宁 jupyter 后 ipython notebook 的浏览器中存在。

更改 /usr/local/share/jupyter/kernels/python3/kernel.json 后有效。 那里的路径 /usr/bin/python ,将其更改为anaconda one.