Smtplib import email.utils error

I get the following error when I try 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 turn on the library when I work directly with the Python interpreter.

Previously, the file was called "email.py", but according to the answers to stackoverflow regarding similar problems, I changed the name to "myemail.py". It still does not work. Please help.

+6
source share
1 answer

Make sure that there is no email.py in the same directory where myemail.py lives. This will prevent the import of the standard email library module.

Also make sure that there is no email.pyc in this directory.


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

+15
source

Source: https://habr.com/ru/post/977655/


All Articles