When I run python program -not in codecademy environment- It always gives the error 'AttributeError: module ‘seaborn’ has no attribute ‘barplot’ . why it happens?
I’m afraid I never used seaborn for much so hopefully someone else could have more insight. If you output
dir(seaborn) I assume
barplot is not listed? Could it be version related (was barplot introduced at a later date)?
Can you give an example of how you are importing it and how you are using it in your program?
It might be because you’re using an older version of seaborn.
When you import Seaborn, add this to the script to set the parameters:
import seaborn as sns; sns.set()
And, when you import matplot lib, do it like so:
import matplotlib.pyplot as plt
More detail on this here (scroll down to where it discusses Seaborn’s API):
I also found this:
It also could be related to seaborn scripts:
Although possible, I doubt it is due to an older version of Seaborn.
barplot() has been included since March 2014 (version 0.3.0). I think the more likely case is an improper import or a file/folder named seaborn. The answer in @lisalisaj’s third link is spot-on and definitely one of those “gotchas” for newer coders — don’t name your file or folder the same name as an external library you’re trying to import!