Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

smtplib import email.utils error

I am getting the following error when I am trying to use smtplib in my Python code.

Traceback (most recent call last):
File "myemail.py", line 1, in <module>
import smtplib
File "/usr/lib64/python2.7/smtplib.py", line 46, in <module>
import email.utils
ImportError: No module named utils

Surprisingly, I can include the library when I am working from the Python interpreter directly.

Previously the file was named 'email.py', but according to the answers on stackoverflow regarding similar issues, I changed the name to 'myemail.py'. It still is not working. Kindly help.

like image 253
psyc0der Avatar asked Nov 03 '14 15:11

psyc0der


1 Answers

Make sure that there's no email.py in the same directory where the myemail.py lives. That prevent importing of the standard library module email.

Also make sure there are no remaining email.pyc in that directory.


If you use your own email module, rename it with a different name.

like image 96
falsetru Avatar answered Oct 21 '22 04:10

falsetru