【发布时间】:2016-07-07 09:02:15
【问题描述】:
我收到一个奇怪的 NLTK 对齐模块导入错误:
$ python2 --version
Python 2.7.10
$ pip2 freeze | grep nltk
nltk==3.2
$ python2
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>> from nltk.align import AlignedSent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named align
如您所见,我为 python 2.7 安装了 nltk 3.2。我可以直接导入nltk。但是,我无法访问align 模块。
我知道我使用的 import 语句是正确的,因为我直接从 the official documentation 获取它。此外,我查看了the interface changes from NLTK 2 to NLTK 3 并没有提到align 模块。
为什么会发生这种情况,我可以做些什么来解决这个问题?
【问题讨论】:
标签: python nltk python-import python-module