Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

seaborn

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!

like image 435
Hannah Avatar asked Jul 23 '26 02:07

Hannah


2 Answers

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.

like image 167
cyprieng Avatar answered Jul 24 '26 15:07

cyprieng


Just rename your script name from "seaborn.py" to something else.

like image 45
MOhammad Isaac Ahmadi Avatar answered Jul 24 '26 16:07

MOhammad Isaac Ahmadi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!