Reputation: 51
I have anaconda2 in my windows10, and install seaborn by the command:
conda install seaborn
Then I download an example from seaborn website:
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})
After I run the example in my command prompt, it throws the following error:
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'
Has anyone encounterd the same problem? How can I solve it? Thanks!
Upvotes: 3
Views: 15324
Reputation: 31
Just rename your script name from "seaborn.py" to something else.
Upvotes: 2
Reputation: 746
From the stacktrace it seems like your script is named seaborn.py
(File "seaborn.py", line 1, in <module>
... File "E:\OneDrive\seek_backward\caiwufenxi\source\seaborn.py", line 5, in <module>
). Try to rename it in something else (like test1.py
) and retry.
You are actually trying to import your local seaborn script (which doesn't have a load_dataset function) and not the installed module.
Upvotes: 9