Unable to import Python’s email module at all

It looks like you have a file named email.py. Don’t use file names that have the same name as Python standard library modules. Generally, your working directory comes earlier on the Python search path for importing modules so files in your working directory will override modules with the same name in the standard library.

The clue: note the path names in the traceback

  File "email.py", line 1, in <module>
    import smtplib
  File "C:\Python27\lib\smtplib.py", line 46, in <module>
    import email.utils

By the way, this is a very common error. The excellent tutorial in the Python standard documentation set talks about it here.

Leave a Comment