I am trying to import seaborn into python (using 2.7) using the following code:
import matplotlib.pyplot as plt import seaborn as sns import pandas as pd import numpy as np import math as math from pylab import rcParams %matplotlib inline
and getting the following error message:
ImportError Traceback (most recent call last) <ipython-input-62-bd3d27f3b137> in <module>() 1 import matplotlib.pyplot as plt ----> 2 import seaborn as sns 3 import pandas as pd 4 import numpy as np 5 import math as math C:\Python27\lib\site-packages\seaborn\__init__.py in <module>() 2 from .utils import * 3 from .palettes import * ----> 4 from .linearmodels import * 5 from .distributions import * 6 from .timeseries import * C:\Python27\lib\site-packages\seaborn\linearmodels.py in <module>() 19 from .external.six.moves import range 20 ---> 21 from . import utils 22 from . import algorithms as algo 23 from .palettes import color_palette ImportError: cannot import name utils
Can anyone please assist with this? I've tried looking through this site and also Google, but with no luck. Thanks in advance.
First open Spyder and click Tools --> Open command prompt. You should see the Command Window appear in the bottom right of your screen. Here we install the Python package seaborn as an example. This will install seaborn on your machine.
I had faced the same problem. Restarting the notebook solved my problem.
If that doesn't solve the problem, you can try this
pip install seaborn
Edit
As few people have posted in the comments, you can also use
python -m pip install seaborn
Plus, as per https://bugs.python.org/issue22295 it is a better way because in this case, you can specify which version of python (python3 or python2) to use for running pip
As @avp says the bash line pip install seaborn
should work I just had the same problem and and restarting the notebook didn't seem to work but running the command as jupyter line magic was a neat way to fix the problem without restarting the notebook
Jupyter Code-Cell:
%%bash pip install seaborn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With