ModuleNotFoundError: No module named 'seaborn' in Python IDE
Asked Answered
S

17

20

enter image description here

enter image description here

It checks the lib folder where my seaborn stuff is, but still error._.

Hi,
I have looked at other posts, but most seemed to be dealing with Jupyter notebooks, which I'm not. I was wondering how to get to use Seaborn in the basic Python IDE or in PyCharm. I read about filepath collisions stuff, but not too clear on that front.

I'm using Python 3.6 right now.

Thanks for any help!

Stupefacient answered 9/1, 2019 at 19:3 Comment(6)
Do you have other versions of Python3?Tentacle
What does that mean? Like also Python 3.7? If so, I do have MiniConda Python 3.7. Should I remove that?Stupefacient
please include a screen shot of where you have python 3 installedPlaylet
From terminal open idle, using idle3, since you are using python 3.6, then do import seaborn. Do not use idle as it will open 2.7 version.Comorin
Please do not share information as images unless absolutely necessary. See: meta.#304312, idownvotedbecau.se/imageofcode, idownvotedbecau.se/imageofanexception.Loudmouthed
We need more information on your environment.Loudmouthed
S
2

In PyCharm IDE, we can import the downloaded libraries, and that's what I did. Still, I have no clue on how to resolve this issue on Python IDE, but as of now, it's working on PyCharm for me.

Stupefacient answered 19/6, 2019 at 18:28 Comment(0)
A
26

When dealing with version ambiguity, remember that pip is a python module. Once you're confident that python is the python installation that your IDE is running, run

python --version
python -m pip install seaborn

>pip3 may be pointing to an old or different python installation.

Almena answered 9/1, 2019 at 19:48 Comment(2)
imgur.com/a/r2Qiz7R Wait, does the Python IDE have to exactly match? I have python 3.6.0 installed, but my Python IDE is for 3.6.6Stupefacient
That definitely means they're not pointing to the same python installation, and almost definitely that's what causing the issue. Your python 3.6.0 installation has seaborn installed correctly, but the python 3.6.6 installation that the IDE is calling does not. If I were you, I might actually uninstall python 3.6.0 entirely, if you don't have a very specific version requirement.Almena
L
16
import pip
pip.main(['install','seaborn'])

From: https://stackoverflow.com/a/49391839

Leverett answered 9/2, 2021 at 3:6 Comment(0)
P
6

If you're doing in jupyter notebook Try doing this:

!conda install -c anaconda seaborn -y
Pokeberry answered 5/3, 2020 at 21:37 Comment(2)
If you're doing in jupyter notebook That's clearly not the case, since OP wrote I have looked at other posts, but most seemed to be dealing with Jupyter notebooks, which I'm not.Loudmouthed
The default install command with conda is conda install seaborn, letting conda manage the default source per local configuration (configuration exists for good reasons, in particular for using conda-forge repository rather than anaconda). So if you are suggesting to not use the local configuration (c and y options force to use anaconda blindly without confirmation) then explain why...Warehouseman
F
5

Try running it in the terminal, it will work. But while running the command your pwd should be in the virtual environment in activated form

$ sudo apt-get install -y python3-seaborn
Fertilize answered 18/12, 2020 at 4:38 Comment(1)
Please explain why this is a solution. What does your solution do, how does it solve the problem. (It should also have an educational effect on people who find this question because they have a similar problem. )Lach
C
4

If you are using jupyter notebook following command will solve the issue

!pip install seaborn
Cartelize answered 13/8, 2021 at 5:36 Comment(2)
This advice is outdated if you are using modern Jupyter. (Not Google Colab, which is an outdated fork built off open source Jupyter resources.) If you are not using Anaconda/conda as your primary package manager, you can run inside the running .ipynb file %pip install seaborn. Note that is using the magic version of the install command that works in multiple places, even JupyterLite. See here for more about the modern magic install commands added a few years ...Piebald
<continued> ago to run inside a running .ipynb file to insure the install occurs in the environment where the kernel is running. The exclamation point in conjunction with install commands can lead to a problem because it doesn't insure the environment is correct. See the second paragraph here for more about how the exclamation point use with installs can lead to issues and confusion. Therefore the version of the install command with the exclamation point is best not recommended.Piebald
T
2

Try running this in a command line 'pip install seaborn'

https://seaborn.pydata.org/installing.html#installing

Tangled answered 9/1, 2019 at 19:27 Comment(1)
imgur.com/a/r2Qiz7R Already did both "pip install seaborn" and "pip3 install seaborn" :/Stupefacient
S
2

In PyCharm IDE, we can import the downloaded libraries, and that's what I did. Still, I have no clue on how to resolve this issue on Python IDE, but as of now, it's working on PyCharm for me.

Stupefacient answered 19/6, 2019 at 18:28 Comment(0)
T
2

Conda install seaborn worked in my case.

Thumping answered 7/4, 2020 at 8:43 Comment(0)
F
1

Jupyter Code-Cell:

%%bash

pip install seaborn
Filling answered 15/12, 2019 at 13:22 Comment(1)
Welcome to Stack Overflow. It would be helpful if you could write how to use your code and how it would solve the problem.Streamline
C
0

open using idle3

open using idle

Since you are using python 3, try to open with idle3 from terminal

Comorin answered 9/1, 2019 at 19:32 Comment(1)
I only have the Python 3.6.X IDE. I checked the sys.path and it includes the folder that contains my seaborn folder but still import errorStupefacient
S
0

Tried importing seaborn in Pycharm with the proper configuration thing, and it works. I still don't know why the regular Python IDE doesn't work even though one of the sys.path folder it checks contains the seaborn folder, but oh well.
Thanks for all the replies!

Stupefacient answered 10/1, 2019 at 6:55 Comment(0)
X
0

Maybe you should try “python —version “to check if you’re using the right version of python in cmd. Sometimes it happens that there are multiple versions installed and it sometimes picks the wrong one.

Also it can happens that python hasn’t the rights to use the module. Then you should create your file and run it with “python [path of file]”

Xerarch answered 10/1, 2019 at 7:2 Comment(0)
F
0

Just found a new method to install all important libraries. Open command prompt: Pip install pyforest All the most important libraries got installed.

Filling answered 16/12, 2019 at 15:42 Comment(0)
T
0

My fix (Same import error but on Jupyter Notebook). The import sequence:

import numpy as np
import seaborn as sns
%matplotlib inline
import matplotlib.pyplot as plt

Importing Matplotlib before seaborn can lead to an import error (I have no idea why).

The Seaborn official document also shows this: https://seaborn.pydata.org/installing.html

Trixie answered 29/4, 2021 at 8:14 Comment(0)
L
0

If you're using Jupyter notebook try to run this:

pip install seaborn --user
Lorrettalorri answered 22/2, 2023 at 13:32 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Ruling
I
0

I recommend you to use seaborn under Anaconda environment. I met same condition as you, but when I use online Jupyter Notebook, it works. If you don't want to use the web version, like running the code this locality, you can download Jupyter notebook and Anaconda. And choose the Anaconda as your kernel. If you use vs code, you can refer to this official statement: https://code.visualstudio.com/docs/datascience/jupyter-notebooks

Illjudged answered 8/9, 2023 at 5:14 Comment(0)
S
0

enter image description here

pip install seaborn

enter image description here

[![enter image description here][3]][3]

import seaborn as sns

sns.set_theme()

tips = sns.load_dataset("tips")

sns.relplot( data=tips, x="total_bill", y="tip", col="time", hue="smoker", style="smoker", size="size", ) [3]: https://i.sstatic.net/ZId3H.png

Swank answered 30/12, 2023 at 6:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.