我正在尝试运行以下代码
from ngram import NGram
NGram.compare('foo', 'foobar')
但我收到了错误
Traceback (most recent call last):
File "E:/pt/tandra", line 1, in <module>
from ngram import Ngram
ImportError: No module named ngram
可能是什么原因。 ngram文件夹与文件
位于同一目录中答案 0 :(得分:2)
你没有名为ngram的模块。你需要安装它。 只需使用
easy_install ngram
或
pip install ngram
在终端(适用于Linux,Mac OS,Windows中的Cygwin)中,如果你有python setuptools。