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

有些话、适合烂在心里 提交于 2020-05-24 01:51:55

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/41158789/seaborn-attributeerror-module-object-has-no-attribute-set

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!