AttributeError: 模块 'matplotlib' 没有属性 'interactive'

Har*_*vey 3 python matplotlib jupyter-notebook

%matplotlib inline在 Jupyter 笔记本中使用时,出现错误:

AttributeError: 模块 'matplotlib' 没有属性 'interactive'

这就是问题。

我也在stackoverflow 中提到过这个问题, 但我找不到答案。

我试过这个:

%matplotlib --list
Run Code Online (Sandbox Code Playgroud)

发现了这个:

可用的 matplotlib 后端:['tk', 'gtk', 'gtk3', 'wx', 'qt4', 'qt5', 'qt', 'osx', 'nbagg', 'notebook', 'agg', ' svg', 'pdf', 'ps', 'inline', 'ipympl', 'widget']

它表明,我inline在我的 matplotlib 中有但无法使用它。

我也试过:

import matplotlib.pyplot as plt
Run Code Online (Sandbox Code Playgroud)

不使用%matplotlib inline但发现此错误:

ModuleNotFoundError:没有名为“matplotlib.pyplot”的模块

然后,我尝试在我的 conda venv 中安装此模块并收到此错误: 错误 请帮帮我:)

Har*_*vey 8

我的解决方案是从我的 conda 环境中删除 matplot lib,这也强制删除了依赖项。再次运行安装后:

conda install -c conda-forge matplotlib
Run Code Online (Sandbox Code Playgroud)

一切都很好。