在Python中导入imaplib包时出错

时间:2017-07-31 05:02:26

标签: python nltk python-3.5 python-import imaplib

我正在尝试在Python解释器中导入imaplib并获得与nltk相关的以下错误。

>>> import imaplib

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File 
"C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\imaplib.py", 
line 25, in <module>
import binascii, errno, random, re, socket, subprocess, sys, time, calendar
File
C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\subprocess.py", 
line 427, in<module>
import threading
File 
"C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\threading.py", 
line 7, in <module>
from traceback import format_exc as _format_exc
File 
"C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\traceback.py", 
line 5, in <module>
import linecache
File 
"C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\linecache.py", 
line 11, in <module>
import tokenize
File "C:\Users\nikhsin2\python\tokenize.py", line 1, in <module>
import nltk
File "C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\site-
packages\nltk\__init__.py", line 114, in <module>
from nltk.collocations import *
File "C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\site-
packages\nltk\collocations.py", line 38, in <module>
from nltk.util import ngrams
File "C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\site-
packages\nltk\util.py", line 15, in <module>
import pydoc
File 
"C:\Users\nikhsin2\AppData\Local\Programs\Python\Python35\lib\pydoc.py", 
line 72, in <module>
from traceback import format_exception_only
ImportError: cannot import name 'format_exception_only'

我正在尝试创建一个桌面应用程序,用于执行一些与邮件相关的操作。 浏览了很多,但没有找到任何解决方案。 nltk软件包已经安装。

1 个答案:

答案 0 :(得分:1)

Python的imaplib不依赖于nltk。但是看起来你的目录中有一个名为tokenize.py的脚本,它被导入而不是预期的依赖关系:仔细查看你所包含的跟踪中的路径。