tomitokko/20-python-projects

unable to import module email.message, error showing email is not a package

Closed this issue · 5 comments

when I am running the code of email.sender file its showing that email.message is not the module and code not working.
from email.message import EmailMessage
ModuleNotFoundError: No module named 'email.message'; 'email' is not a package

Your suggestions will be highly appreciated.

@Boby900 Hey, a quick search on stackoverflow and I found this thread, hope it helps.

"I encountered the same problem just now. Finally, I found it's because I name the python file as 'email.py'. It works after changing its name"

"Don't use "email" in your .py file name or even in package name as well. This will cause confusion to the interpreter between user declared module and pre-defined modules"

@Boby900 Did the above-mentioned suggestion work? or you found another work around?

I am sorry, currently I am not working on these.
but I will do it in meantime.

i had a same problem