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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With