1

When ever I try to import smtplib in the Python interpreter, I get this error:

ImportError: cannot import name fix_eols 

How can I fix this?

Edit: Here is the full stack trace:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 46, in <module> import email.utils File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 32, in <module> from email._parseaddr import quote File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/_parseaddr.py", line 16, in <module> import time, calendar File "/Users/aaronblock/Documents/programming/scripts/calendar.py", line 7, in <module> File "/usr/local/lib/python2.7/site-packages/apiclient/__init__.py", line 19, in <module> from googleapiclient import discovery File "/usr/local/lib/python2.7/site-packages/googleapiclient/discovery.py", line 38, in <module> from email.generator import Generator File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/generator.py", line 15, in <module> from email.header import Header File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/header.py", line 16, in <module> import email.quoprimime File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/quoprimime.py", line 49, in <module> from email.utils import fix_eols ImportError: cannot import name fix_eols 
2
  • Please include the full stack trace. Commented Dec 1, 2015 at 15:22
  • @horns I added the full stack trace Commented Dec 1, 2015 at 15:27

2 Answers 2

4

Just to point out how to detect this kinds of errors (since it does happen from time to time):

Pay attention to the stacktrace. In this example, the problem can be seen in the line:

File "/Users/aaronblock/Documents/programming/scripts/calendar.py", line 7, in <module> 

which certainly indicates wrong file being imported when we're trying to import a system-wide library.

Sign up to request clarification or add additional context in comments.

Comments

0

I had a file called "calendar.py" which messes up my Python environment because smtplib needs calendar.py in order to work. Deleting calendar.py solved my problem.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.