Click here to Skip to main content
15,034,432 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
when I Import seaborn as sns I get the following error
Traceback (most recent call last):
  File "C:/python/seaborn testing.py", line 1, in <module>
    import seaborn as sns
  File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\site-packages\seaborn\__init__.py", line 2, in <module>
    from .rcmod import *  # noqa: F401,F403
  File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\site-packages\seaborn\rcmod.py", line 7, in <module>
    from . import palettes
  File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\site-packages\seaborn\palettes.py", line 9, in <module>
    from .utils import desaturate, get_color_cycle
  File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\site-packages\seaborn\utils.py", line 7, in <module>
    from urllib.request import urlopen, urlretrieve
  File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 86, in <module>
    import email
  File "C:/python\email.py", line 3, in <module>
    import smtplib
  File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 47, in <module>
    import email.utils
ModuleNotFoundError: No module named 'email.utils'; 'email' is not a package


What I have tried:

I have tried uninstall seaborn and reinstalling it
I also tried installing utils and also tried uninstalling scipy and reinstalling it
I tried uninstalling requests and reinstalling it I also tried upgrading seaborn but it did not fix the error.
Posted
Updated 6-Dec-20 19:09pm

1 solution

Is this Seaborn or smtplib problem? You might be using Seaborn for the graphing purposes, but the error comes from the smtplib package that is being used.
Quote:
ModuleNotFoundError: No module named 'email.utils'; 'email' is not a package
One of the reasons that this error happen is because you "might" have an "email" file within your directory. Python is very notorious when it comes to variables/naming. It doesn't warn you when you are overriding another name (thus leading to such problems).

Once I was using the list as a variable name for my Python program, and Python allowed me to use the name, but only later when I wanted to create a list it kept telling me that list is not a method and I cannot call it.

Try removing any email files from your local code and see if it works.

On a side note, (I have not tried this package you are using yet!), have you tried using from emails import utils?
   
v2
Comments
vishesh rocks 7-Dec-20 4:58am
   
I am not using the smtplib package. and i also dont have any email files in my local code/directory
this was the code I had used with the seaborn module just to check if seborn is working:-
import seaborn as sns
df = sns.load_dataset("penguins")
sns.pairplot(df, hue="species")
and then got the error
Afzaal Ahmad Zeeshan 7-Dec-20 11:47am
   
If you are not using smtplib, then why does your code show the statements from that package?


File "C:/python\email.py", line 3, in <module>
import smtplib
File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 47, in <module>
import email.utils
ModuleNotFoundError: No module named 'email.utils'; 'email' is not a package
vishesh rocks 8-Dec-20 4:02am
   
that is what I dont know and that's why I am asking for help
Afzaal Ahmad Zeeshan 8-Dec-20 11:26am
   
Right, what code are you using?

If you are using the example code/SDK, then the problem is with their code; or maybe you missed a step while setting up the SDK.
vishesh rocks 10-Dec-20 2:16am
   
i have not set up any environment in python. and there cant be anything wrong with the code because when running
import seaborn as sns also i get the same error.
vishesh rocks 11-Dec-20 1:22am
   
none of it works although this problem occurs only with seaborn not with any other module

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900