2015-12-01 61 views
1

當過我嘗試import smtplib在Python解釋器,我得到這個錯誤:不能`進口smtplib`

ImportError: cannot import name fix_eols 

我該如何解決這個問題?

編輯: 以下是完整的堆棧跟蹤:

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 
+0

請包括完整的堆棧跟蹤。 – horns

+0

@horns我添加了完整的堆棧跟蹤 – blockaj

回答

3

只是想指出如何檢測這種類型的錯誤(因爲它確實發生不時):

,請注意堆棧跟蹤。在這個例子中,這個問題可以看出該行:

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

這無疑表明錯誤的文件,當我們試圖導入一個全系統的庫被導入。

0

我有一個名爲「calendar.py」,因爲需要的smtplib爲了工作calendar.py這打亂了我的Python環境的文件。刪除calendar.py解決了我的問題。

相關問題