gpt4 book ai didi

python - seaborn 属性错误 : 'module' object has no attribute 'set'

转载 作者:行者123 更新时间:2023-11-28 21:44:07 25 4
gpt4 key购买 nike

我的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.py ( File "seaborn.py", line 1, in <module> ... File "E:\OneDrive\seek_backward\caiwufenxi\source\seaborn.py", line 5, in <module> )。尝试将其重命名为其他名称(例如 test1.py )并重试。

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

关于python - seaborn 属性错误 : 'module' object has no attribute 'set' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41158789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com