Forums

ModuleNotFoundError while importing seaborn as sns

Hi,

I am getting ModuleNotFoundError while importing seaborn as sns in ipynb python version 3.6 ModuleNotFoundError Traceback (most recent call last) <ipython-input-11-ed9806ce3570> in <module>() ----> 1 import seaborn as sns

ModuleNotFoundError: No module named 'seaborn'

(ML-virtualenv) 15:45 ~ $ pip install seaborn
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: seaborn in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (0.9.0)
Requirement already satisfied: pandas>=0.15.2 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from seaborn) (0.23.4)
Requirement already satisfied: numpy>=1.9.3 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from seaborn) (1.15.4)
Requirement already satisfied: scipy>=0.14.0 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from seaborn) (1.2.0)
Requirement already satisfied: matplotlib>=1.4.3 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from seaborn) (3.0.2)
Requirement already satisfied: pytz>=2011k in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from pandas>=0.15.2->seaborn) (2018.7)
Requirement already satisfied: python-dateutil>=2.5.0 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from pandas>=0.15.2->seaborn) (2. 7.5)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from matplotlib>=1.4.3->seaborn) (1.0. 1)
Requirement already satisfied: cycler>=0.10 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from matplotlib>=1.4.3->seaborn) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from matplotlib

=1.4.3->seaborn) (2.3.0)
Requirement already satisfied: six>=1.5 in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas>=0.15.2->se aborn) (1.12.0)
Requirement already satisfied: setuptools in ./.virtualenvs/ML-virtualenv/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib>=1.4.3->se aborn) (40.6.3)

Are you running your notebook with the ML-virtualenv python kernel? See this.

Tried the option , still getting the same error with IPYNB. I was able to successfully import numpy and matplotlib having this issue with Seaborn.

It works fine when i execute from bash console. (ML-virtualenv) 15:35 ~/.virtualenvs/ML-virtualenv $ python Python 3.6.0 (default, Jan 13 2017, 00:00:00) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information.

import seaborn as sns

Just now created another virtualenv and still seeing the same error. Following are the steps that i have done. 1. Opened the bash console under the .virtualenvs folder 2. $ mkvirtualenv my-virtualenv-ML --python=python3.6 - executed successfully 3. pip install seaborn - executed successfully 4. under the my-virtualenv-ML , created a new IPYNB 3.6 file - executed successfully 5. Import seaborn as sns - getting the ModuleNotFoundError.

Please let me know if i have missed anything.

I think there might be a bit of confusion here about how to make the notebook use a specific virtualenv. It doesn't matter which directory you create it in (so there's no need to put it inside the virtualenv's directory). You need to select the correct kernel from the Kernel -> Change kernel menu inside the notebook. You should see my-virtualenv-ML as an option there.

Sorry for the delay in response, i don't see my-virtualenv-ML or any other virtual environments that i have created. When i select Kernel-> Change kernel, i am seeing an option to change the python version from 2.7 to 3.6.

Ah, sorry -- I forgot one step. You need to install a couple of things into your virtualenv:

workon my-virtualenv-ML
pip install tornado==4.5.3
pip install ipykernel==4.8.2

Once you've done that, the virtualenv kernel should appear ion the list -- you may need to refresh the page showing the notebook first.

Have installed bot tornado and ipykernel in my virtual environment( my-virtualenv-ML), but still not able to see the virtualenv kernel.

I believe you also need to run python -m ipykernel install --user from within your virtualenv to actually install it

I have executed the command python -m ipykernel install --user , but still i am unable to view the virtualenv kernel.

Please look into it.

I see you've emailed us about this -- we'll pick up the conversation on that thread.