seaborn AttributeError: 'module' object has no attribute 'set'

seaborn AttributeError: 'module' object has no attribute 'set'

我的windows10里有anaconda2,通过命令安装seaborn:

conda install seaborn

然后我从seaborn网站下载了一个例子:

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

# Load the example dataset for Anscombe's quartet
df = sns.load_dataset("anscombe")

# Show the results of a linear regression within each dataset
sns.lmplot(x="x", y="y", col="dataset", hue="dataset", data=df,
       col_wrap=2, ci=None, palette="muted", size=4,
       scatter_kws={"s": 50, "alpha": 1})

在我的命令提示符中 运行 示例后,它抛出以下错误:

Traceback (most recent call last):
  File "seaborn.py", line 1, in <module>
    import seaborn as sns
  File "E:\OneDrive\seek_backward\caiwufenxi\source\seaborn.py", line 5, in   <module>
  df = sns.load_dataset("anscombe")
AttributeError: 'module' object has no attribute 'load_dataset'

有没有人遇到过同样的问题?我该如何解决?谢谢!

从堆栈跟踪来看,您的脚本似乎名为 seaborn.pyFile "seaborn.py", line 1, in <module>...File "E:\OneDrive\seek_backward\caiwufenxi\source\seaborn.py", line 5, in <module>)。尝试用其他名称重命名它(例如 test1.py)并重试。

您实际上是在尝试导入本地 seaborn 脚本(没有 load_dataset 函数)而不是已安装的模块。

只需将您的脚本名称从“seaborn.py”重命名为其他名称即可。