Error "ModuleNotFoundError: No module named seaborn", but the package seaborn is up to date

Error "ModuleNotFoundError: No module named seaborn", but the package seaborn is up to date

我是运行画图的简单代码:

import seaborn as sns
sns.set(style="darkgrid")

# Load an example dataset with long-form data
fmri = sns.load_dataset("fmri")

# Plot the responses for different events and regions
sns.lineplot(x="timepoint", y="signal",
             hue="region", style="event",
             data=fmri)

然后我收到错误消息

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-b0fb62af2e98> in <module>
----> 1 import seaborn as sns
      2 sns.set(style="darkgrid")
      3 
      4 # Load an example dataset with long-form data
      5 fmri = sns.load_dataset("fmri")

ModuleNotFoundError: No module named 'seaborn'

这是我的 JupyterLab 的屏幕截图:

这对我来说很奇怪,因为我使用 Anaconda 并且软件包 seaborn 是最新的。

能否请您告诉我如何修复此代码?非常感谢!

我刚刚发现我的系统中有两个 python 发行版,一个来自 Anaconda(已经安装了软件包 seaborn)。另一个没有包seaborn。我从后者打开 JupyterLab。这就是问题所在。