0

I am using from Python prompt in Ubuntu machine, the following is working fine:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders

However, when I am trying to run the above as a part of script from Ubuntu command prompt or terminal I am getting the following error:

    Traceback (most recent call last):
  File "/home/ubuntu/fraud/app/email.py", line 9, in <module>
    import smtplib
  File "/usr/lib/python3.8/smtplib.py", line 47, in <module>
    import email.utils
  File "/home/ubuntu/fraud/app/email.py", line 11, in <module>
    from email.mime.multipart import MIMEMultipart
  ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package

Can't really figure out what am I missing here.

pythondumb
  • 1,187
  • 1
  • 15
  • 30

1 Answers1

-1

had same error few days ago,i just used this instead

pip install secure-smtplib
Eyal Solomon
  • 470
  • 1
  • 6
  • 15
  • Do you have a file called email.py in your source code? Rename it. https://stackoverflow.com/questions/33313858/importerror-no-module-named-email-mime-email-is-not-a-package – vinzenz Jun 01 '21 at 13:56